Class OntSimpleClassImpl

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.OntSimpleClassImpl
All Implemented Interfaces:
org.apache.jena.graph.FrontsNode, OntClass, OntObject, org.apache.jena.rdf.model.RDFNode, org.apache.jena.rdf.model.Resource
Direct Known Subclasses:
OntSimpleClassImpl.NamedImpl

public class OntSimpleClassImpl extends OntObjectImpl implements OntClass
Simple Ontology Class implementation. Represents RDFS OntClass or OWL OntClass with unknown nature. Specialized OWL classes have their own implementations (OntSimpleClassImpl.NamedImpl or OntClassImpl).
  • Constructor Details

    • OntSimpleClassImpl

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

    • findRootStatement

      public Optional<OntStatement> findRootStatement()
      Description copied from class: OntObjectImpl
      Finds the first declaration root statement. The graph may contain several triples with predicate rdf:type and this ontology object as a subject. In this case, the result is unpredictable.
      Overrides:
      findRootStatement in class OntObjectImpl
      Returns:
      Optional around OntStatement that supports plain annotation assertions
    • objectType

      public Class<? extends OntClass> 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
    • createIndividual

      public OntIndividual.Anonymous createIndividual()
      Description copied from interface: OntClass
      Creates an anonymous individual which is of this class-expression type.
      Specified by:
      createIndividual in interface OntClass
      Returns:
      OntIndividual.Anonymous
      See Also:
    • createIndividual

      public OntIndividual.Named createIndividual(String uri)
      Description copied from interface: OntClass
      Creates a named individual which is of this class type.
      Specified by:
      createIndividual in interface OntClass
      Parameters:
      uri - String, not null
      Returns:
      OntIndividual.Named
      See Also:
    • superClasses

      public Stream<OntClass> superClasses(boolean direct)
      Description copied from interface: OntClass
      Answers a Stream over the class-expressions for which this class expression is declared a subclass. The return Stream is distinct and this instance is not included in it.

      The flag direct allows some selectivity over the classes that appear in the Stream. Consider the following scenario:

      
         :A rdfs:subClassOf :B .
         :A rdfs:subClassOf :C .
         :C rdfs:subClassOf :D .
       
      (so A has superclasses B and C, and C has superclass D) In a raw model, with no inference support, listing the superclasses of A will answer B and C. In an inferencing model, rdfs:subClassOf is known to be transitive, so the superclasses iterator will include D. The direct superclasses are those members of the closure of the inverse-subClassOf relation, restricted to classes that cannot be reached by a longer route, i.e., the ones that are directly adjacent to the given root. Thus, the direct superclasses of A are B and C only, and not D - even in an inferencing graph. Note that this is not the same as the entailments from the raw graph. Suppose we add to this example:
      
         :A rdfs:subClassOf :D .
       
      Now, in the raw graph, A has superclasses B, C, D. But the direct superclasses of A remain only B and C, since there is a longer path A-C-D that means that D is not a direct superclass of A. The assertion in the raw graph that A has superclass D is essentially redundant, since this can be inferred from the closure of the graph.
      Specified by:
      superClasses in interface OntClass
      Parameters:
      direct - boolean: if true answers the directly adjacent classes in the superclass relation, i.e., eliminate any class for which there is a longer route to reach that parent under the superclass relation; if false answers all superclasses found by inferencer, which usually means entire hierarchy up the tree; this class is not included
      Returns:
      distinct Stream of super class expressions
      See Also:
    • subClasses

      public Stream<OntClass> subClasses(boolean direct)
      Description copied from interface: OntClass
      Answers a Stream over all the class expressions that are declared to be subclasses of this class expression. The return Stream is distinct and this instance is not included in it. The flag direct allows some selectivity over the classes that appear in the Stream. Consider the following scenario:
      
         :B rdfs:subClassOf :A.
         :C rdfs:subClassOf :A.
         :D rdfs:subClassOf :C.
       
      (so A has two subclasses, B and C, and C has subclass D) In a raw model, with no inference support, listing the subclasses of A will answer B and C. In an inferencing model, rdfs:subClassOf is known to be transitive, so the subclasses iterator will include D. The direct subclasses are those members of the closure of the subClassOf relation, restricted to classes that cannot be reached by a longer route, i.e., the ones that are directly adjacent to the given root. Thus, the direct subclasses of A are B and C only, and not D - even in an inferencing graph. Note that this is not the same as the entailments from the raw graph. Suppose we add to this example:
      
         :D rdfs:subClassOf :A.
       
      Now, in the raw graph, A has subclass C. But the direct subclasses of A remain B and C, since there is a longer path A-C-D that means that D is not a direct subclass of A. The assertion in the raw graph that A has subclass D is essentially redundant, since this can be inferred from the closure of the graph.
      Specified by:
      subClasses in interface OntClass
      Parameters:
      direct - boolean - if true answers the directly adjacent classes in the subclass relation: i.e., eliminate any class for which there is a longer route to reach that parent under the subclass relation; if false answers all subclasses found by inferencer, which usually means entire hierarchy down the tree; this class is not included
      Returns:
      distinct Stream of sub class expressions
      See Also:
    • individuals

      public Stream<OntIndividual> individuals(boolean direct)
      Description copied from interface: OntClass
      Lists all individuals, directly or indirectly connected to this class. The search pattern is a rdf:type C, where C is class expression and a individual.
      Specified by:
      individuals in interface OntClass
      Parameters:
      direct - boolean if true, only direct instances are counted (i.e., not instances of subclasses of this class)
      Returns:
      a Stream of OntIndividuals
    • hasDeclaredProperty

      public boolean hasDeclaredProperty(OntProperty property, boolean direct)
      Description copied from interface: OntClass
      Returns true if the given property is associated with a frame-like view of this class. This captures an informal notion of the properties of a class, by looking at the domains of the property in this class's model, and matching them to this class. A full description of the frame-like view of a class may be found in: Apache Jena: RDF frames how-to for full details.

      Note that many cases of determining whether a property is associated with a class depend on RDFS or OWL reasoning. This method may therefore return complete results only in models that have an attached reasoner. For built-in properties the method returns always false. If there are no domains for the property, then it is considered as global and is attached to root classes.

      Specified by:
      hasDeclaredProperty in interface OntClass
      Parameters:
      property - OntProperty, not null
      direct - boolean: if true analyses only the directly adjacent domains in the subclass relation, otherwise takes into account the class hierarchy
      Returns:
      boolean, true if the property is associated with this class by its domain, otherwise false
    • declaredProperties

      public Stream<OntProperty> declaredProperties(boolean direct)
      Description copied from interface: OntClass
      Returns a Stream over the properties associated with a frame-like view of this class. This captures an intuitive notion of the properties of a class. This can be useful in presenting an ontology class in a user interface, for example, by automatically constructing a form to instantiate instances of the class. The properties in the frame-like view of the class are determined by comparing the domain of properties in this class's OntModel with the class itself. See: Apache Jena: Presenting RDF as frames for more details.
      Specified by:
      declaredProperties in interface OntClass
      Parameters:
      direct - boolean: if true analyses only the directly adjacent domains in the subclass relation, otherwise takes into account the class hierarchy
      Returns:
      a distinct Stream of object, datatype and annotation properties, attached to this class
      See Also:
    • isHierarchyRoot

      public boolean isHierarchyRoot()
      Description copied from interface: OntClass
      Answers true if this class is one of the roots of the local class hierarchy. This will be true if either (i) this class has either owl:Thing or rdfs:Resource as a direct superclass, or (ii) it has no declared superclasses.

      owl:Nothing cannot be root.

      Specified by:
      isHierarchyRoot in interface OntClass
      Returns:
      true if this class is the root of the class hierarchy in the model it is attached to
    • createHasKey

      Description copied from interface: OntClass
      Creates a HasKey logical construction as ontology []-list of Object or Data Property Expressions that is attached to this Class Expression using the predicate owl:hasKey. The resulting rdf-list will consist of all the elements of the specified collection in the same order but with exclusion of duplicates. Note: nulls in the collection will cause exception. For additional information about HasKey logical construction see 9.5 Keys specification.
      Specified by:
      createHasKey in interface OntClass
      Parameters:
      ope - Collection (preferably Set) of object property expressions
      dpe - Collection (preferably Set) of data property expressions
      Returns:
      OntList of OntRelationalPropertys
      See Also:
    • addHasKeyStatement

      public OntStatement addHasKeyStatement(OntRelationalProperty... properties)
      Description copied from interface: OntClass
      Creates a HasKey logical construction as ontology list and returns the statement C owl:hasKey ( P1 ... Pm R1 ... Rn ) to allow the subsequent addition of annotations. About RDF Graph annotation specification sees, for example, 2.3.1 Axioms that Generate a Main Triple.
      Specified by:
      addHasKeyStatement in interface OntClass
      Parameters:
      properties - Array of OntRelationalPropertys without nulls
      Returns:
      OntStatement with a possibility to annotate
      See Also:
    • hasKeys

      public Stream<OntList<OntRelationalProperty>> hasKeys()
      Description copied from interface: OntClass
      Lists all HasKey ontology []-lists that are attached to this class expression on predicate owl:hasKey.
      Specified by:
      hasKeys in interface OntClass
      Returns:
      Stream of OntLists with parameter-type OntDOP
    • removeHasKey

      public OntSimpleClassImpl removeHasKey(org.apache.jena.rdf.model.Resource list) throws OntJenaException.IllegalArgument
      Description copied from interface: OntClass
      Deletes the given HasKey list including its annotations.
      Specified by:
      removeHasKey in interface OntClass
      Parameters:
      list - Resource can be OntList or RDFList; if null the method will remove all hasKey's
      Returns:
      this instance to allow cascading calls
      Throws:
      OntJenaException.IllegalArgument
    • isDisjoint

      public boolean isDisjoint(org.apache.jena.rdf.model.Resource candidate)
      Description copied from interface: OntClass
      Answers true if this class is disjoint with the given class.
      Specified by:
      isDisjoint in interface OntClass
      Parameters:
      candidate - Resource a class to test
      Returns:
      true if this class is disjoint with the given class
    • disjointClasses

      public Stream<OntClass> disjointClasses()
      Description copied from interface: OntClass
      Returns disjoint class-objects. This includes thisClass owl:disjointWith otherClass, otherClass owl:disjointWith thisClass statements and owl:AllDisjointClasses construct.
      Specified by:
      disjointClasses in interface OntClass
      Returns:
      a Stream of OntClasss
      See Also:
    • equivalentClasses

      public Stream<OntClass> equivalentClasses()
      Description copied from interface: OntClass
      Lists all equivalent classes. The statement patter to search for is C1 owl:equivalentClass C2.
      Specified by:
      equivalentClasses in interface OntClass
      Returns:
      Stream of OntClasss
      See Also:
    • hasSuperClass

      public boolean hasSuperClass(OntClass clazz, boolean direct)
      Description copied from interface: OntClass
      Answers true if the given class is a superclass of this class. See OntClass.superClasses(boolean) for a full explanation of the direct parameter
      Specified by:
      hasSuperClass in interface OntClass
      Parameters:
      clazz - a OntClass to test
      direct - boolean; If true, only search the classes that are directly adjacent to this class in the class hierarchy.
      Returns:
      boolean
    • addDisjointClass

      public OntClass addDisjointClass(OntClass other)
      Description copied from interface: OntClass
      Adds the given class as a disjoint class and returns this class expression instance to allow cascading calls.
      Specified by:
      addDisjointClass in interface OntClass
      Parameters:
      other - OntClass, not null
      Returns:
      this instance to allow cascading calls
      See Also:
    • addDisjointWithStatement

      public OntStatement addDisjointWithStatement(OntClass other)
      Description copied from interface: OntClass
      Adds the given class as a disjoint class and returns the corresponding statement to provide the ability to add annotations.
      Specified by:
      addDisjointWithStatement in interface OntClass
      Parameters:
      other - OntClass, not null
      Returns:
      OntStatement to allow the subsequent annotations addition
      See Also:
    • removeDisjointClass

      public OntClass removeDisjointClass(org.apache.jena.rdf.model.Resource other)
      Description copied from interface: OntClass
      Removes the specified disjoint class resource. No-op in case no match found. Removes all owl:disjointWith statements with all their annotations in case null is specified.
      Specified by:
      removeDisjointClass in interface OntClass
      Parameters:
      other - Resource, or null to remove all disjoint classes
      Returns:
      this instance to allow cascading calls
      See Also:
    • addEquivalentClassStatement

      public OntStatement addEquivalentClassStatement(OntClass other)
      Description copied from interface: OntClass
      Adds the given class as an equivalent class and returns the corresponding statement to provide the ability to add annotations.
      Specified by:
      addEquivalentClassStatement in interface OntClass
      Parameters:
      other - OntClass, not null
      Returns:
      OntStatement to allow the subsequent annotations addition
      See Also:
    • removeEquivalentClass

      public OntClass removeEquivalentClass(org.apache.jena.rdf.model.Resource other)
      Description copied from interface: OntClass
      Removes the given equivalent class resource including the statement's annotations. No-op in case no match found. Removes all owl:equivalentClass statements with all their annotations in case null is specified.
      Specified by:
      removeEquivalentClass in interface OntClass
      Parameters:
      other - Resource, or null to remove all equivalent classes
      Returns:
      this instance 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)