Class OwlapiUtils
java.lang.Object
cz.cvut.kbss.ontodriver.owlapi.util.OwlapiUtils
Utility methods for the OWLAPI driver.
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.semanticweb.owlapi.model.OWLLiteralcreateOWLLiteralFromValue(Object value, String lang) Creates OWLLiteral from the specified Java instance.static booleandoesLanguageMatch(org.semanticweb.owlapi.model.OWLLiteral literal, Assertion assertion) Checks whether the specified literal matches to the language of the specified assertion.static StringgetAssertionLanguage(Assertion assertion) Retrieves language from the specified assertion.static org.semanticweb.owlapi.model.OWLNamedIndividualgetIndividual(NamedResource subject, org.semanticweb.owlapi.model.OWLDataFactory dataFactory) Gets OWLNamedIndividual for the specified named resource.static booleanisIndividualIri(Object value) Checks whether the specified value is a valid IRI.static ObjectowlLiteralToValue(org.semanticweb.owlapi.model.OWLLiteral owlLiteral) Transforms OWLLiteral to a plain Java object (boxed primitive or date/time).
-
Method Details
-
createOWLLiteralFromValue
public static org.semanticweb.owlapi.model.OWLLiteral createOWLLiteralFromValue(Object value, String lang) Creates OWLLiteral from the specified Java instance.- Parameters:
value- The value to transformlang- Ontology language- Returns:
- OWLLiteral representing the value
- Throws:
IllegalArgumentException- Ifvalueis of unsupported type
-
owlLiteralToValue
Transforms OWLLiteral to a plain Java object (boxed primitive or date/time).- Parameters:
owlLiteral- The literal to transform- Returns:
- Transformed value
- Throws:
IllegalArgumentException- If the literal is of unsupported type
-
doesLanguageMatch
public static boolean doesLanguageMatch(org.semanticweb.owlapi.model.OWLLiteral literal, Assertion assertion) Checks whether the specified literal matches to the language of the specified assertion.If the literal is not a string, it automatically matches. If it is a string, it matches if assertion language is not specified, it is without language tag or if the language tag matches the specified assertion language.
- Parameters:
literal- Literal to checkassertion- Assertion with language specification (possibly empty)- Returns:
trueif the literal matches the assertion language,falseotherwise
-
getAssertionLanguage
Retrieves language from the specified assertion.If the assertion does not specify language,
Constants.DEFAULT_LANGUAGEis returned.- Parameters:
assertion- Assertion to get language for- Returns:
- Assertion language or default language
-
getIndividual
public static org.semanticweb.owlapi.model.OWLNamedIndividual getIndividual(NamedResource subject, org.semanticweb.owlapi.model.OWLDataFactory dataFactory) Gets OWLNamedIndividual for the specified named resource.- Parameters:
subject- Named resource to transform to individualdataFactory- OWL data factory- Returns:
- OWLNamedIndividual
-
isIndividualIri
Checks whether the specified value is a valid IRI.Only absolute IRIs are accepted.
- Parameters:
value- The value to check- Returns:
truefor instances ofNamedResource,URI,URLorIRIand for Strings parseable byURI.create(String).
-