Interface OntID

All Superinterfaces:
org.apache.jena.graph.FrontsNode, OntObject, org.apache.jena.rdf.model.RDFNode, org.apache.jena.rdf.model.Resource
All Known Implementing Classes:
OntIDImpl

public interface OntID extends OntObject
Interface encapsulating an Ontology Identifier. Each OWL2 Obtology must have one and only one Ontology ID inside.

Please note: the methods of this interface do not affect the hierarchical structure of the graph to which this resource is attached, they only affect the structure of the graph itself. In other words, calling the methods removeImport(String) does not remove the sub-graph from the main Union Graph. Similar, calling the method addImport(String) simply adds the corresponding triple to the base graph.

See Also:
  • Method Details

    • getVersionIRI

      String getVersionIRI()
      Returns an IRI from the right side of this owl:versionIRI IRI statement if it is uniquely determined.
      Returns:
      String IRI or null
    • setVersionIRI

      OntID setVersionIRI(String uri) throws OntJenaException
      Assigns a new version IRI to this Ontology ID object. A null argument means that current version IRI should be deleted.
      Parameters:
      uri - String, can be null to remove versionIRI
      Returns:
      this ID-object to allow cascading calls
      Throws:
      OntJenaException - if input is wrong
    • addImport

      OntID addImport(String uri) throws OntJenaException
      Adds the triple this owl:import uri to this resource.
      Parameters:
      uri - String, not null
      Returns:
      this ID-object to allow cascading calls
      Throws:
      OntJenaException - if input is wrong
    • removeImport

      OntID removeImport(String uri)
      Removes the triple this owl:import uri from this resource.
      Parameters:
      uri - String, not null
      Returns:
      this ID-object to allow cascading calls
    • imports

      Stream<String> imports()
      Lists all owl:imports.
      Returns:
      Stream of Strings (IRIs)
    • sameAs

      default boolean sameAs(OntID other)
      Indicates whether the given Ontology ID is equal to this one in OWL2 terms. This means that the IDs must have the same IRI + version IRI pairs. If the method returns true, then two ontologies can not be coexisting in the same scope.
      Parameters:
      other - OntID
      Returns:
      true in case the IDs are the same, otherwise false
    • getImportsIRI

      default String getImportsIRI()
      Returns an IRI that can be used to create owl:imports statement in another model to make a reference between a model to which this id belongs and another model. According to the specification, a version IRI is primary.
      Returns:
      String or null
      See Also:
    • addComment

      default OntID addComment(String txt)
      Creates _:this rdfs:comment "txt"^^xsd:string statement.
      Specified by:
      addComment in interface OntObject
      Parameters:
      txt - String, not null
      Returns:
      this object to allow cascading calls
      See Also:
    • addComment

      default OntID addComment(String txt, String lang)
      Adds the given localized text annotation with builtin rdfs:comment predicate.
      Specified by:
      addComment in interface OntObject
      Parameters:
      txt - String, the literal lexical form, not null
      lang - String, the language tag, nullable
      Returns:
      this object to allow cascading calls
      See Also:
    • addVersionInfo

      default OntID addVersionInfo(String txt)
      Adds a owl:versionInfo description.
      Parameters:
      txt - String, the literal lexical form, not null
      Returns:
      this ID-object to allow cascading calls
    • addVersionInfo

      default OntID addVersionInfo(String txt, String lang)
      Annotates this object with owl:versionInfo predicate and the specified language-tagged literal.
      Parameters:
      txt - String, the literal lexical form, not null
      lang - String, the language tag, nullable
      Returns:
      this ID-object to allow cascading calls
    • getVersionInfo

      default String getVersionInfo()
      Answers the version info string for this ontology id. If there is more than one such resource, an arbitrary selection is made.
      Returns:
      a owl:versionInfo string or null if nothing is found
    • getVersionInfo

      default String getVersionInfo(String lang)
      Answers the version info string for this ontology id. If there is more than one such resource, an arbitrary selection is made.
      Parameters:
      lang - String, the language attribute for the desired comment (EN, FR, etc.) or null for don't care; will attempt to retrieve the most specific comment matching the given language; to get no-lang literal string an empty string can be used
      Returns:
      a owl:versionInfo string matching the given language, or null if there is no version info
    • annotate

      default OntID annotate(OntAnnotationProperty predicate, String txt, String lang)
      Adds a language-tagged text for this object and the given predicate
      Specified by:
      annotate in interface OntObject
      Parameters:
      predicate - OntAnnotationProperty - named annotation property, not null
      txt - String, the literal lexical form, cannot be null
      lang - String, the language tag, can be null
      Returns:
      this object to allow cascading calls
    • annotate

      default OntID annotate(OntAnnotationProperty predicate, org.apache.jena.rdf.model.RDFNode value)
      Annotates the object with the given predicate and value.
      Specified by:
      annotate in interface OntObject
      Parameters:
      predicate - OntAnnotationProperty - named annotation property, not null
      value - RDFNode - the value: uri-resource, literal or anonymous individual, not null
      Returns:
      this object to allow cascading calls
      See Also:
    • getModel

      OntModel getModel()
      Returns the ontology model associated with this resource. If the Resource was not created by a Model, the result may be null.
      Specified by:
      getModel in interface org.apache.jena.rdf.model.RDFNode
      Returns:
      OntModel
    • isLocal

      boolean isLocal()
      Determines if this Ontology Resource is locally defined. This means that the resource definition (i.e., a the root statement) belongs to the base ontology graph. If the ontology contains subgraphs (which should match owl:imports in OWL) and the resource is defined in one of them, than this method called from top-level interface will return false.
      Returns:
      true if this resource is local to the base model graph.
    • getAs

      default <X extends org.apache.jena.rdf.model.RDFNode> X getAs(Class<X> type)
      Safely converts this RDF resource to the given type interface, if it is possible. Otherwise, returns null. A calling of this method is effectively equivalent to the expression this.canAs(type) ? this.as(type) : null.
      Type Parameters:
      X - any subtype of RDFNode
      Parameters:
      type - a Class-type of the desired RDF view (interface)
      Returns:
      an instance of the type X or null
      See Also:
      • RDFNode.as(Class)
      • RDFNode.canAs(Class)