Package edu.stanford.bmir.protege.web.server

Source Code of edu.stanford.bmir.protege.web.server.RdfsLabelWithLexicalValueAndLang

package edu.stanford.bmir.protege.web.server;

import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom;
import org.semanticweb.owlapi.model.OWLAnnotationValue;
import org.semanticweb.owlapi.model.OWLLiteral;

/**
* @author Matthew Horridge, Stanford University, Bio-Medical Informatics Research Group, Date: 19/04/2014
*/
public class RdfsLabelWithLexicalValueAndLang extends TypeSafeMatcher<OWLAnnotationAssertionAxiom> {

    private String expectedValue;

    private String lang;

    public RdfsLabelWithLexicalValueAndLang(String expectedValue, String lang) {
        this.expectedValue = expectedValue;
    }

    @Override
    protected boolean matchesSafely(OWLAnnotationAssertionAxiom item) {
        if(!item.getProperty().isLabel()) {
            return false;
        }
        OWLAnnotationValue value = item.getValue();
        return value instanceof OWLLiteral && ((OWLLiteral) value).getLiteral().equals(expectedValue)
                && lang.equals(((OWLLiteral) value).getLang());
    }

    @Override
    public void describeTo(Description description) {
        description.appendText("rdfs:Label annotation assertion with \"" + expectedValue + "\" value");
    }

    public static RdfsLabelWithLexicalValueAndLang rdfsLabelWithLexicalValueAndLang(String lexicalValue, String lang) {
        return new RdfsLabelWithLexicalValueAndLang(lexicalValue, lang);
    }
}
TOP

Related Classes of edu.stanford.bmir.protege.web.server.RdfsLabelWithLexicalValueAndLang

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.