Interface OntProperty

All Superinterfaces:
org.apache.jena.graph.FrontsNode, OntObject, org.apache.jena.rdf.model.RDFNode, org.apache.jena.rdf.model.Resource
All Known Subinterfaces:
OntAnnotationProperty, OntDataProperty, OntObjectProperty, OntObjectProperty.Inverse, OntObjectProperty.Named, OntRelationalProperty
All Known Implementing Classes:
OntAnnotationPropertyImpl, OntDataPropertyImpl, OntObjectPropertyImpl, OntObjectPropertyImpl.InversePropertyImpl, OntObjectPropertyImpl.NamedImpl, OntPropertyImpl, OntSimplePropertyImpl

public interface OntProperty extends OntObject
An abstraction for any Ontology Property Expression. In OWL2 there are four such property expressions: Data Property, Object Property (OWL Entity and InverseOf) and Annotation Property.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default OntStatement
    addDomainStatement(org.apache.jena.rdf.model.Resource domain)
    Adds a statement $this rdfs:domain $domain.
    default OntStatement
    addRangeStatement(org.apache.jena.rdf.model.Resource range)
    Adds range statement $this rdfs:range $range.
    default OntStatement
    addSubPropertyOfStatement(org.apache.jena.rdf.model.Resource property)
    Adds the given property as super property returning a new statement to annotate.
    org.apache.jena.rdf.model.Property
    Returns a named part of this property expression.
    declaringClasses(boolean direct)
    Answers a Stream of all the classes in this ontology, such that each returned class has this property as one of its properties in OntClass.declaredProperties(boolean).
    Stream<? extends org.apache.jena.rdf.model.Resource>
    Lists all property domains.
    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.
    Returns the ontology model associated with this resource.
    default boolean
    hasSubProperty(OntProperty property, boolean direct)
    Answers true if the given property is a sub-property of this property.
    default boolean
    hasSuperProperty(OntProperty property, boolean direct)
    Answers true if the given property is a super-property of this property.
    boolean
    Determines if this Ontology Resource is locally defined.
    Stream<? extends org.apache.jena.rdf.model.Resource>
    Lists all property ranges.
    default OntProperty
    removeDomain(org.apache.jena.rdf.model.Resource domain)
    Removes the specified domain resource (predicate is rdfs:domain), including the corresponding statement's annotations.
    default OntProperty
    removeRange(org.apache.jena.rdf.model.Resource range)
    Removes the specified range resource (predicate is rdfs:range), including the corresponding statement's annotations.
    default OntProperty
    removeSubProperty(org.apache.jena.rdf.model.Resource property)
    Removes the specified sub property (predicate is rdfs:subPropertyOf), including the corresponding statement's annotations.
    default OntProperty
    removeSuperProperty(org.apache.jena.rdf.model.Resource property)
    Removes the specified super property (predicate is rdfs:subPropertyOf), including the corresponding statement's annotations.
    default Stream<? extends OntProperty>
    Lists all the properties that are declared to be sub-properties of this property (directly or indirectly).
    Stream<? extends OntProperty>
    subProperties(boolean direct)
    Answers a Stream over all the properties that are declared to be sub-properties of this property.
    default Stream<? extends OntProperty>
    Lists all the properties that are declared to be super-properties of this property (directly or indirectly).
    Stream<? extends OntProperty>
    superProperties(boolean direct)
    Answers a Stream over all the properties that are declared to be super-properties of this property.

    Methods inherited from interface org.apache.jena.graph.FrontsNode

    asNode

    Methods inherited from interface org.apache.jena.rdf.model.RDFNode

    as, asLiteral, asResource, canAs, isAnon, isLiteral, isResource, isStmtResource, isURIResource, visitWith

    Methods inherited from interface org.apache.jena.rdf.model.Resource

    abort, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addProperty, addProperty, addProperty, addProperty, begin, commit, equals, getId, getLocalName, getNameSpace, getProperty, getProperty, getPropertyResourceValue, getRequiredProperty, getStmtTerm, getURI, hasLiteral, hasLiteral, hasLiteral, hasLiteral, hasLiteral, hasLiteral, hasProperty, hasProperty, hasProperty, hasProperty, hasURI, inModel, listProperties, listProperties, listProperties, removeAll, removeProperties, toString
  • Method Details

    • asProperty

      org.apache.jena.rdf.model.Property asProperty()
      Returns a named part of this property expression.
      Returns:
      Property
    • subProperties

      Stream<? extends OntProperty> subProperties(boolean direct)
      Answers a Stream over all the properties that are declared to be sub-properties of this property. Each element of the Stream will have the same type as this property instance: if it is datatype property the method will return only data properties, etc. The parameter direct controls selectivity over the properties that appear in the Stream. Consider the following scenario:
      
        :D rdfs:subPropertyOf :C .
        :C rdfs:subPropertyOf :A .
        :B rdfs:subPropertyOf :A .
       
      (so A has two sub-properties, B and C, and C has sub-property D) In a raw model, with no inference support, listing the sub-property of A will answer B and C. In an inferencing model, rdfs:subPropertyOf is known to be transitive, so the sub-properties iterator will include D. The direct sub-properties are those members of the closure of the subPropertyOf relation, restricted to properties that cannot be reached by a longer route, i.e., the ones that are directly adjacent to the given root. Thus, the direct sub-properties of A are B and C only, and not D - even in an inferencing graph. Note that this is different from the entailments from the raw graph. Suppose we add to this example:
      
         :D rdfs:subPropertyOf :A.
       
      Now, in the raw graph, A has sub-property C. But the direct sub-properties of A remain B and C, since there is a longer path A-C-D that means that D is not a direct sub-property of A. The assertion in the raw graph that A has sub-property D is essentially redundant, since this can be inferred from the closure of the graph.
      Parameters:
      direct - boolean - if true answers the directly adjacent properties in the sub-property relation: i.e. eliminate any properties for which there is a longer route to reach that parent under the sub-property relation; if false answers all sub-properties found by inferencer, which usually means entire hierarchy down the tree; this property is not included
      Returns:
      distinct Stream of properties with the same type as this property
      See Also:
    • superProperties

      Stream<? extends OntProperty> superProperties(boolean direct)
      Answers a Stream over all the properties that are declared to be super-properties of this property. Each element of the Stream will have the same type as this property instance: if it is datatype property the method will return only data properties, etc. The parameter direct controls selectivity over the properties that appear in the Stream. Consider the following scenario:
      
        :A rdfs:subPropertyOf :B .
        :A rdfs:subPropertyOf :C .
        :C rdfs:subPropertyOf :D .
        
      (so A has super-property B and C, and C has super-property D) In a raw model, with no inference support, listing the super-property of A will answer B and C. In an inferencing model, rdfs:subPropertyOf is known to be transitive, so the super-property iterator will include D. The direct super-properties are those members of the closure of the inverse-subPropertyOf relation, restricted to properties that cannot be reached by a longer route, i.e., the ones that are directly adjacent to the given root. Thus, the direct super-property of A are B and C only, and not D - even in an inferencing graph. Note that this is different from the entailments from the raw graph. Suppose we add to this example:
      
         :A rdfs:subPropertyOf :D .
       
      Now, in the raw graph, A has super-property B, C, D. But the direct super-property of A remain only B and C, since there is a longer path A-C-D that means that D is not a direct super-property of A. The assertion in the raw graph that A has super-property D is essentially redundant, since this can be inferred from the closure of the graph.
      Parameters:
      direct - boolean: if true answers the directly adjacent properties in the super-property relation, i.e. eliminate any property for which there is a longer route to reach that parent under the super-property relation; if false answers all super-properties found by inferencer, which usually means entire hierarchy up the tree; this instance is not included
      Returns:
      distinct Stream of properties with the same type as this property
      See Also:
    • domains

      Stream<? extends org.apache.jena.rdf.model.Resource> domains()
      Lists all property domains.
      Returns:
      Stream of Resources
      See Also:
    • ranges

      Stream<? extends org.apache.jena.rdf.model.Resource> ranges()
      Lists all property ranges.
      Returns:
      Stream of Resources
      See Also:
    • declaringClasses

      Stream<OntClass> declaringClasses(boolean direct)
      Answers a Stream of all the classes in this ontology, such that each returned class has this property as one of its properties in OntClass.declaredProperties(boolean). This simulates a frame-like view of properties and classes; for more details see the Apache Jena: Presenting RDF as frames
      Parameters:
      direct - boolean if true, use only direct associations between classes and properties
      Returns:
      a Stream of the classes having this property as one of their declared properties
    • subProperties

      default Stream<? extends OntProperty> subProperties()
      Lists all the properties that are declared to be sub-properties of this property (directly or indirectly). Note: the return elements have the same type as this instance.

      Equivalent to this.subProperties(false).

      Returns:
      Stream of ont-properties
      See Also:
    • superProperties

      default Stream<? extends OntProperty> superProperties()
      Lists all the properties that are declared to be super-properties of this property (directly or indirectly). Note: the return elements have the same type as this instance.

      Equivalent to this.superProperties(false).

      Returns:
      Stream of ont-properties
      See Also:
    • hasSubProperty

      default boolean hasSubProperty(OntProperty property, boolean direct)
      Answers true if the given property is a sub-property of this property. See subProperties(boolean) for a full explanation of the direct parameter.
      Parameters:
      property - a OntProperty to test
      direct - boolean; If true, only search the properties that are directly adjacent to this property in the class hierarchy
      Returns:
      boolean
    • hasSuperProperty

      default boolean hasSuperProperty(OntProperty property, boolean direct)
      Answers true if the given property is a super-property of this property. See superProperties(boolean) for a full explanation of the direct parameter.
      Parameters:
      property - a OntProperty to test
      direct - boolean; If true, only search the properties that are directly adjacent to this property in the class hierarchy
      Returns:
      boolean
    • addSubPropertyOfStatement

      default OntStatement addSubPropertyOfStatement(org.apache.jena.rdf.model.Resource property)
      Adds the given property as super property returning a new statement to annotate. The triple pattern is $this rdfs:subPropertyOf $property).
      Parameters:
      property - Resource, not null
      Returns:
      OntStatement to allow subsequent annotations adding
    • addRangeStatement

      default OntStatement addRangeStatement(org.apache.jena.rdf.model.Resource range)
      Adds range statement $this rdfs:range $range.
      Parameters:
      range - Resource, not null
      Returns:
      OntStatement to allow subsequent annotations adding
    • addDomainStatement

      default OntStatement addDomainStatement(org.apache.jena.rdf.model.Resource domain)
      Adds a statement $this rdfs:domain $domain.
      Parameters:
      domain - Resource, not null
      Returns:
      OntStatement to allow the subsequent addition of annotations
    • removeDomain

      default OntProperty removeDomain(org.apache.jena.rdf.model.Resource domain)
      Removes the specified domain resource (predicate is rdfs:domain), including the corresponding statement's annotations. No-op in case no such domain is found. Removes all domains if null is specified.
      Parameters:
      domain - Resource, or null to remove all domains
      Returns:
      this instance to allow cascading calls
    • removeRange

      default OntProperty removeRange(org.apache.jena.rdf.model.Resource range)
      Removes the specified range resource (predicate is rdfs:range), including the corresponding statement's annotations. No-op in case no such range is found. Removes all ranges if null is specified.
      Parameters:
      range - Resource, or null to remove all ranges
      Returns:
      this instance to allow cascading calls
    • removeSuperProperty

      default OntProperty removeSuperProperty(org.apache.jena.rdf.model.Resource property)
      Removes the specified super property (predicate is rdfs:subPropertyOf), including the corresponding statement's annotations. No-op in case no such super-property is found. If null is specified, the method removes all triples with predicate rdfs:subPropertyOf and this property as a subject.
      Parameters:
      property - Resource or null to remove all direct super properties
      Returns:
      this instance to allow cascading calls
    • removeSubProperty

      default OntProperty removeSubProperty(org.apache.jena.rdf.model.Resource property)
      Removes the specified sub property (predicate is rdfs:subPropertyOf), including the corresponding statement's annotations. No-op in case no such super-property is found. If null is specified, the method removes all triples with predicate rdfs:subPropertyOf and this property as an object.
      Parameters:
      property - Resource or null to remove all direct super properties
      Returns:
      this instance to allow cascading calls
    • 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)