Class ReadHelper

java.lang.Object
com.github.owlcs.ontapi.internal.ReadHelper

public class ReadHelper extends Object
A collection of helper methods to perform translation of RDF-Graph to the OWLObjects (i.e. reading from a Graph).

Created by @ssz on 25.11.2016.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static ONTObject<? extends org.semanticweb.owlapi.model.OWLClassExpression>
    calcClassExpression(org.apache.jena.ontapi.model.OntClass ce, ONTObjectFactory of, Set<org.apache.jena.rdf.model.Resource> seen)
    Calculates an OWLClassExpression wrapped by ONTObject.
    static ONTObject<? extends org.semanticweb.owlapi.model.OWLDataRange>
    calcDataRange(org.apache.jena.ontapi.model.OntDataRange dr, ONTObjectFactory of, Set<org.apache.jena.rdf.model.Resource> seen)
    Calculates an OWLDataRange wrapped by ONTObject.
    static org.semanticweb.owlapi.model.OWLFacetRestriction
    calcOWLFacetRestriction(org.apache.jena.ontapi.model.OntFacetRestriction fr, ONTObjectFactory of)
    Creates an OWLFacetRestriction instance.
    static ONTObject<? extends org.semanticweb.owlapi.model.SWRLAtom>
    calcSWRLAtom(org.apache.jena.ontapi.model.OntSWRL.Atom<?> atom, ONTObjectFactory of)
     
    static ONTObject<org.semanticweb.owlapi.model.OWLAnnotation>
    getAnnotation(org.apache.jena.ontapi.model.OntStatement ann, ONTObjectFactory of)
    Translates OntStatement to ONTObject encapsulated OWLAnnotation.
    static org.semanticweb.owlapi.vocab.OWLFacet
    getFacet(Class<? extends org.apache.jena.ontapi.model.OntFacetRestriction> type)
    Gets the facet by ONT-API type.
    static ONTObject<org.semanticweb.owlapi.model.OWLFacetRestriction>
    getFacetRestriction(org.apache.jena.ontapi.model.OntFacetRestriction fr, ONTObjectFactory of)
    Maps OntFacetRestriction => OWLFacetRestriction.
    static ONTObject<? extends org.semanticweb.owlapi.model.SWRLIArgument>
    getSWRLIndividualArg(org.apache.jena.ontapi.model.OntSWRL.IArg arg, ONTObjectFactory of)
     
    static ONTObject<? extends org.semanticweb.owlapi.model.SWRLDArgument>
    getSWRLLiteralArg(org.apache.jena.ontapi.model.OntSWRL.DArg arg, ONTObjectFactory of)
     
    static ONTObject<org.semanticweb.owlapi.model.SWRLVariable>
    getSWRLVariable(org.apache.jena.ontapi.model.OntSWRL.Variable var, ONTObjectFactory of)
     
    static boolean
    isAnnotationAssertionStatement(org.apache.jena.ontapi.model.OntStatement s, AxiomsSettings config)
    Answers if the given OntStatement can be considered as annotation property assertion.
    static boolean
    isDeclarationStatement(org.apache.jena.ontapi.model.OntStatement s)
    Answers true if the given OntStatement is a declaration (predicate = rdf:type) of some OWL entity or anonymous individual.
    static boolean
    isEntityOrAnonymousIndividual(org.apache.jena.rdf.model.Resource o)
    Answers true if the given Resource is an OWL-Entity or Anonymous Individual
    static org.apache.jena.util.iterator.ExtendedIterator<ONTObject<org.semanticweb.owlapi.model.OWLAnnotation>>
    listAnnotations(org.apache.jena.ontapi.model.OntStatement statement, AxiomsSettings conf, ONTObjectFactory factory)
    Lists all OWLAnnotations which are associated with the specified statement.
    static org.apache.jena.util.iterator.ExtendedIterator<ONTObject<org.semanticweb.owlapi.model.OWLAnnotation>>
    listOWLAnnotations(org.apache.jena.ontapi.model.OntObject obj, ONTObjectFactory of)
    Lists all annotations related to the object (including assertions).
    static boolean
    testAnnotationAxiomOverlaps(org.apache.jena.ontapi.model.OntStatement statement, AxiomsSettings conf, org.semanticweb.owlapi.model.AxiomType<? extends org.semanticweb.owlapi.model.OWLObjectPropertyAxiom> o, org.semanticweb.owlapi.model.AxiomType<? extends org.semanticweb.owlapi.model.OWLDataPropertyAxiom> d)
    Auxiliary method for simplification code.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ReadHelper

      public ReadHelper()
  • Method Details

    • testAnnotationAxiomOverlaps

      public static boolean testAnnotationAxiomOverlaps(org.apache.jena.ontapi.model.OntStatement statement, AxiomsSettings conf, org.semanticweb.owlapi.model.AxiomType<? extends org.semanticweb.owlapi.model.OWLObjectPropertyAxiom> o, org.semanticweb.owlapi.model.AxiomType<? extends org.semanticweb.owlapi.model.OWLDataPropertyAxiom> d)
      Auxiliary method for simplification code. Used in Annotation Translators. If the specified statement also belongs to the another type of axiom and such situation is prohibited in the config then returns false. This is for three kinds of statements:
      • A1 rdfs:subPropertyOf A2
      • A rdfs:domain U
      • A rdfs:range U
      Each of them is wider than the analogous statement for object or data property, e.g. P rdfs:range C could be treated as A rdfs:range U, but not vice versa.
      Parameters:
      statement - OntStatement to test, not null
      conf - AxiomsSettings, not null
      o - AxiomType.SUB_OBJECT_PROPERTY or AxiomType.OBJECT_PROPERTY_DOMAIN or AxiomType.OBJECT_PROPERTY_RANGE
      d - AxiomType.SUB_DATA_PROPERTY or AxiomType.DATA_PROPERTY_DOMAIN or AxiomType.DATA_PROPERTY_RANGE
      Returns:
      true if the statement is good to be represented in the form of annotation axiom
    • isDeclarationStatement

      public static boolean isDeclarationStatement(org.apache.jena.ontapi.model.OntStatement s)
      Answers true if the given OntStatement is a declaration (predicate = rdf:type) of some OWL entity or anonymous individual.
      Parameters:
      s - OntStatement to test
      Returns:
      boolean
    • isEntityOrAnonymousIndividual

      public static boolean isEntityOrAnonymousIndividual(org.apache.jena.rdf.model.Resource o)
      Answers true if the given Resource is an OWL-Entity or Anonymous Individual
      Parameters:
      o - Resource
      Returns:
      boolean
    • isAnnotationAssertionStatement

      public static boolean isAnnotationAssertionStatement(org.apache.jena.ontapi.model.OntStatement s, AxiomsSettings config)
      Answers if the given OntStatement can be considered as annotation property assertion.
      Parameters:
      s - OntStatement, not null
      config - AxiomsSettings, not null
      Returns:
      true if the specified statement is annotation property assertion
    • listAnnotations

      public static org.apache.jena.util.iterator.ExtendedIterator<ONTObject<org.semanticweb.owlapi.model.OWLAnnotation>> listAnnotations(org.apache.jena.ontapi.model.OntStatement statement, AxiomsSettings conf, ONTObjectFactory factory)
      Lists all OWLAnnotations which are associated with the specified statement. All OWLAnnotations are provided in the form of ONTObject-wrappers.
      Parameters:
      statement - OntStatement, axiom root statement, not null
      conf - AxiomsSettings, not null
      factory - ONTObjectFactory
      Returns:
      a set of wraps ONTObject around OWLAnnotation
    • listOWLAnnotations

      public static org.apache.jena.util.iterator.ExtendedIterator<ONTObject<org.semanticweb.owlapi.model.OWLAnnotation>> listOWLAnnotations(org.apache.jena.ontapi.model.OntObject obj, ONTObjectFactory of)
      Lists all annotations related to the object (including assertions).
      Parameters:
      obj - OntObject
      of - ONTObjectFactory
      Returns:
      ExtendedIterator of ONTObjects of OWLAnnotation
    • getAnnotation

      public static ONTObject<org.semanticweb.owlapi.model.OWLAnnotation> getAnnotation(org.apache.jena.ontapi.model.OntStatement ann, ONTObjectFactory of)
      Translates OntStatement to ONTObject encapsulated OWLAnnotation.
      Parameters:
      ann - OntStatement
      of - ONTObjectFactory
      Returns:
      ONTObject around OWLAnnotation
    • getFacetRestriction

      public static ONTObject<org.semanticweb.owlapi.model.OWLFacetRestriction> getFacetRestriction(org.apache.jena.ontapi.model.OntFacetRestriction fr, ONTObjectFactory of)
      Maps OntFacetRestriction => OWLFacetRestriction.
      Parameters:
      fr - OntFacetRestriction, not null
      of - ONTObjectFactory, not null
      Returns:
      ONTObject around OWLFacetRestriction
    • calcOWLFacetRestriction

      public static org.semanticweb.owlapi.model.OWLFacetRestriction calcOWLFacetRestriction(org.apache.jena.ontapi.model.OntFacetRestriction fr, ONTObjectFactory of)
      Creates an OWLFacetRestriction instance.
      Parameters:
      fr - OntFacetRestriction, not null
      of - ONTObjectFactory, not null
      Returns:
      OWLFacetRestriction
    • getFacet

      public static org.semanticweb.owlapi.vocab.OWLFacet getFacet(Class<? extends org.apache.jena.ontapi.model.OntFacetRestriction> type)
      Gets the facet by ONT-API type.
      Parameters:
      type - Class-type of OntFacetRestriction
      Returns:
      OWLFacet
      See Also:
    • calcDataRange

      public static ONTObject<? extends org.semanticweb.owlapi.model.OWLDataRange> calcDataRange(org.apache.jena.ontapi.model.OntDataRange dr, ONTObjectFactory of, Set<org.apache.jena.rdf.model.Resource> seen)
      Calculates an OWLDataRange wrapped by ONTObject. Note: this method is recursive.
      Parameters:
      dr - Ontology Data Range to map
      of - ONTObjectFactory
      seen - Set of Resource
      Returns:
      ONTObject around OWLDataRange
      Throws:
      OntApiException - if something is wrong.
    • calcClassExpression

      public static ONTObject<? extends org.semanticweb.owlapi.model.OWLClassExpression> calcClassExpression(org.apache.jena.ontapi.model.OntClass ce, ONTObjectFactory of, Set<org.apache.jena.rdf.model.Resource> seen)
      Calculates an OWLClassExpression wrapped by ONTObject. Note: this method is recursive.
      Parameters:
      ce - Ontology Class Expression to map
      of - ONTObjectFactory
      seen - Set of Resource, a subsidiary collection to prevent possible graph recursions (e.g. _:b0 owl:complementOf _:b0)
      Returns:
      ONTObject around OWLClassExpression
      Throws:
      OntApiException - if something is wrong.
    • getSWRLVariable

      public static ONTObject<org.semanticweb.owlapi.model.SWRLVariable> getSWRLVariable(org.apache.jena.ontapi.model.OntSWRL.Variable var, ONTObjectFactory of)
      Parameters:
      var - OntSWRL.Variable
      of - ONTObjectFactory
      Returns:
      ONTObject around SWRLVariable
    • getSWRLLiteralArg

      public static ONTObject<? extends org.semanticweb.owlapi.model.SWRLDArgument> getSWRLLiteralArg(org.apache.jena.ontapi.model.OntSWRL.DArg arg, ONTObjectFactory of)
      Parameters:
      arg - OntSWRL.DArg
      of - ONTObjectFactory
      Returns:
      ONTObject around SWRLDArgument
    • getSWRLIndividualArg

      public static ONTObject<? extends org.semanticweb.owlapi.model.SWRLIArgument> getSWRLIndividualArg(org.apache.jena.ontapi.model.OntSWRL.IArg arg, ONTObjectFactory of)
      Parameters:
      arg - OntSWRL.IArg
      of - ONTObjectFactory
      Returns:
      ONTObject around SWRLIArgument
    • calcSWRLAtom

      public static ONTObject<? extends org.semanticweb.owlapi.model.SWRLAtom> calcSWRLAtom(org.apache.jena.ontapi.model.OntSWRL.Atom<?> atom, ONTObjectFactory of)
      Parameters:
      atom - OntSWRL.Atom
      of - ONTObjectFactory
      Returns:
      ONTObject around SWRLAtom