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.OWLLiteral
createOWLLiteralFromValue
(Object value, String lang) Creates OWLLiteral from the specified Java instance.static boolean
doesLanguageMatch
(org.semanticweb.owlapi.model.OWLLiteral literal, Assertion assertion) Checks whether the specified literal matches to the language of the specified assertion.static String
getAssertionLanguage
(Assertion assertion) Retrieves language from the specified assertion.static org.semanticweb.owlapi.model.OWLNamedIndividual
getIndividual
(NamedResource subject, org.semanticweb.owlapi.model.OWLDataFactory dataFactory) Gets OWLNamedIndividual for the specified named resource.static boolean
isIndividualIri
(Object value) Checks whether the specified value is a valid IRI.static Object
owlLiteralToValue
(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
- Ifvalue
is 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:
true
if the literal matches the assertion language,false
otherwise
-
getAssertionLanguage
Retrieves language from the specified assertion.If the assertion does not specify language,
Constants.DEFAULT_LANGUAGE
is 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:
true
for instances ofNamedResource
,URI
,URL
orIRI
and for Strings parseable byURI.create(String)
.
-