Class OntAnnotationImpl

java.lang.Object
org.apache.jena.enhanced.Polymorphic<org.apache.jena.rdf.model.RDFNode>
org.apache.jena.enhanced.EnhNode
org.apache.jena.rdf.model.impl.ResourceImpl
org.apache.jena.ontapi.impl.objects.OntObjectImpl
org.apache.jena.ontapi.impl.objects.OntAnnotationImpl
All Implemented Interfaces:
org.apache.jena.graph.FrontsNode, OntAnnotation, OntObject, org.apache.jena.rdf.model.RDFNode, org.apache.jena.rdf.model.Resource

public class OntAnnotationImpl extends OntObjectImpl implements OntAnnotation
The implementation of Annotation Ontology Object. Note: the search is carried out only for the root annotations: the result of snippet model.ontObjects(OntAnnotation.class) would not contain the nested annotations.
  • Field Details

    • REQUIRED_PROPERTIES

      public static final Set<org.apache.jena.rdf.model.Property> REQUIRED_PROPERTIES
    • SPEC

      public static final Set<org.apache.jena.rdf.model.Property> SPEC
    • DEFAULT_ANNOTATION_COMPARATOR

      public static final Comparator<OntAnnotation> DEFAULT_ANNOTATION_COMPARATOR
      The first are annotations with the most numerous assertions and children, the remaining comparison operations are not so important, but the provided order should be preserved after graph reload.
    • EXTRA_ROOT_TYPES

      public static final Set<org.apache.jena.rdf.model.Resource> EXTRA_ROOT_TYPES
    • ROOT_TYPES

      public static final List<org.apache.jena.rdf.model.Resource> ROOT_TYPES
  • Constructor Details

    • OntAnnotationImpl

      public OntAnnotationImpl(org.apache.jena.graph.Node n, org.apache.jena.enhanced.EnhGraph m)
  • Method Details

    • createAnnotation

      public static OntAnnotation createAnnotation(org.apache.jena.rdf.model.Model model, org.apache.jena.rdf.model.Statement base, org.apache.jena.rdf.model.Resource type)
      Creates a new annotation b-node resource with the given type and base statement.
      Parameters:
      model - Model
      base - base ont-statement
      type - owl:Axiom or owl:Annotation
      Returns:
      OntAnnotation the anonymous resource with a specified type.
    • listRelatedStatements

      public static org.apache.jena.util.iterator.ExtendedIterator<OntStatement> listRelatedStatements(OntAnnotation annotation)
      Lists annotation assertions plus sub-annotation root statements.
      Parameters:
      annotation - OntAnnotation
      Returns:
      ExtendedIterator of OntStatements
    • listSpec

      public org.apache.jena.util.iterator.ExtendedIterator<OntStatement> listSpec()
      Description copied from class: OntObjectImpl
      Lists all object's characteristic statements according to its OWL2 specification.
      Overrides:
      listSpec in class OntObjectImpl
      Returns:
      ExtendedIterator of OntStatements
    • getBase

      public OntStatement getBase()
      Description copied from interface: OntAnnotation
      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.
      Specified by:
      getBase in interface OntAnnotation
      Returns:
      OntStatement, possibly null
    • listAssertions

      public org.apache.jena.util.iterator.ExtendedIterator<OntStatement> listAssertions()
      Description copied from class: OntObjectImpl
      Returns an iterator over object's annotation property assertions. The annotation assertion is a statements with an annotation property as predicate.
      Overrides:
      listAssertions in class OntObjectImpl
      Returns:
      ExtendedIterator of OntStatements
      See Also:
    • listAnnotations

      public org.apache.jena.util.iterator.ExtendedIterator<OntStatement> listAnnotations()
      Description copied from class: OntObjectImpl
      Lists all related annotation assertions.
      Overrides:
      listAnnotations in class OntObjectImpl
      Returns:
      ExtendedIterator of OntStatements
      See Also:
    • descendants

      public Stream<OntAnnotation> descendants()
      Description copied from interface: OntAnnotation
      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 OntAnnotation.parent() called on descendants must return the annotation equals to this.
      Specified by:
      descendants in interface OntAnnotation
      Returns:
      Stream of OntAnnotations
    • listDescendants

      public org.apache.jena.util.iterator.ExtendedIterator<OntAnnotation> listDescendants()
      Returns an iterator over all descendants of this ont-annotation resource.
      Returns:
      ExtendedIterator of OntAnnotations
    • addAnnotation

      public OntStatement addAnnotation(OntAnnotationProperty property, org.apache.jena.rdf.model.RDFNode value)
      Description copied from class: OntObjectImpl
      Adds an annotation assertion. It could be expanded to a bulk form by adding sub-annotation.
      Specified by:
      addAnnotation in interface OntAnnotation
      Specified by:
      addAnnotation in interface OntObject
      Overrides:
      addAnnotation in class OntObjectImpl
      Parameters:
      property - OntAnnotationProperty, Named annotation property.
      value - RDFNode the value: uri-resource, literal or anonymous individual.
      Returns:
      OntStatement for newly added annotation
      See Also:
    • objectType

      public Class<? extends OntObject> objectType()
      Description copied from class: OntObjectImpl
      Gets a public ont-object type identifier.
      Specified by:
      objectType in interface OntObject
      Overrides:
      objectType in class OntObjectImpl
      Returns:
      Class, the actual type of this object
    • 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)