Class OwlapiUtils

java.lang.Object
cz.cvut.kbss.ontodriver.owlapi.util.OwlapiUtils

public class OwlapiUtils extends Object
Utility methods for the OWLAPI driver.
  • 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 transform
      lang - Ontology language
      Returns:
      OWLLiteral representing the value
      Throws:
      IllegalArgumentException - If value is of unsupported type
    • owlLiteralToValue

      public static Object owlLiteralToValue(org.semanticweb.owlapi.model.OWLLiteral owlLiteral)
      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 check
      assertion - Assertion with language specification (possibly empty)
      Returns:
      true if the literal matches the assertion language, false otherwise
    • getAssertionLanguage

      public static String getAssertionLanguage(Assertion assertion)
      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 individual
      dataFactory - OWL data factory
      Returns:
      OWLNamedIndividual
    • isIndividualIri

      public static boolean isIndividualIri(Object value)
      Checks whether the specified value is a valid IRI.

      Only absolute IRIs are accepted.

      Parameters:
      value - The value to check
      Returns:
      true for instances of NamedResource, URI, URL or IRI and for Strings parseable by URI.create(String).