Interface OntAnnotation

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

public interface OntAnnotation extends OntObject
A Bulk Annotation Ontology Object. It's an anonymous jena-resource with one of the two types:
  • owl:Axiom for root annotations, it is usually owned by axiomatic statements.
  • owl:Annotation for sub-annotations, and also for annotation of several specific axioms with main-statement _:x rdf:type @type where @type is owl:AllDisjointClasses, owl:AllDisjointProperties, owl:AllDifferent or owl:NegativePropertyAssertion.
Example:

 [ a                      owl:Axiom ;
   rdfs:comment           "some comment 1", "some comment 2"@fr ;
   owl:annotatedProperty  rdf:type ;
   owl:annotatedSource    <Class> ;
   owl:annotatedTarget    owl:Class
 ] .
 

See Also:
  • Method Details

    • getBase

      OntStatement getBase()
      Returns the base statement, i.e. statement to which this bulk-annotation is attached. In the example above it is the statement <Class> rdf:type owl:Class. Notes: Starting v.2.0.0 the presence of this statement in the Graph does not require anymore. The result could be null in the special case of anonymous resource, e.g. when rdf:type is owl:AllDisjointClasses, see class description.
      Returns:
      OntStatement, possibly null
    • assertions

      Stream<OntStatement> assertions()
      Returns the annotations assertions attached to this annotation resource. The annotation assertion is a statements with an annotation property as predicate. The example above contains two such statements: _:x rdfs:comment "some comment 1" and _:x rdfs:comment "some comment 2"@fr.
      Returns:
      Stream of annotation statements OntStatements
      See Also:
    • descendants

      Stream<OntAnnotation> descendants()
      Lists all descendants of this ont-annotation resource. The resulting resources must have owl:Annotation type and this object on predicate owl:annotatedSource. The method parent() called on descendants must return the annotation equals to this.
      Returns:
      Stream of OntAnnotations
    • annotations

      Stream<OntStatement> annotations()
      Just a synonym for assertions().
      Specified by:
      annotations in interface OntObject
      Returns:
      Stream of annotation statements OntStatements
      See Also:
    • addAnnotation

      OntStatement addAnnotation(OntAnnotationProperty property, org.apache.jena.rdf.model.RDFNode value)
      Adds a new annotation assertion to this annotation resource. If this OntAnnotation contains annotation property assertion this x y and it does not have sub-annotations yet, the given annotation property p and value v will produce following OntAnnotation object:
      
       _:x rdf:type              owl:Annotation .
       _:x p                     v .
       _:x owl:annotatedSource   this .
       _:x owl:annotatedProperty x .
       _:x owl:annotatedTarget   y .
       
      and this method will return _:x p v triple wrapped as OntStatement to allow adding subsequent sub-annotations. If this annotation object already has a sub-annotation for the statement this x y, the new triple will be added to the existing anonymous resource.
      Specified by:
      addAnnotation in interface OntObject
      Parameters:
      property - OntAnnotationProperty
      value - RDFNode
      Returns:
      OntStatement - an annotation assertion belonging to this object
      See Also:
    • parent

      default Optional<OntAnnotation> parent()
      Answers a parent OntAnnotation. For non-empty result the rdf:type must be owl:Annotation. For a root annotation an empty result is expected.
      Returns:
      Optional around of OntAnnotation
    • 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)