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
Simple Ontology Class implementation.
Represents RDFS OntClass or OWL OntClass with unknown nature.
Specialized OWL classes have their own implementations (
OntSimpleClassImpl.NamedImpl
or OntClassImpl
).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Primary (named) class (<uri> a owl:Class
).static class
A version of Named class for RL specification.Nested classes/interfaces inherited from interface org.apache.jena.ontapi.model.OntClass
OntClass.CardinalityRestriction<O extends OntObject,
P extends OntRelationalProperty>, OntClass.CollectionOf<O extends OntObject>, OntClass.ComplementOf, OntClass.ComponentRestriction<O extends org.apache.jena.rdf.model.RDFNode, P extends OntRelationalProperty>, OntClass.DataAllValuesFrom, OntClass.DataCardinality, OntClass.DataHasValue, OntClass.DataMaxCardinality, OntClass.DataMinCardinality, OntClass.DataSomeValuesFrom, OntClass.HasSelf, OntClass.IntersectionOf, OntClass.LogicalExpression, OntClass.Named, OntClass.NaryDataAllValuesFrom, OntClass.NaryDataSomeValuesFrom, OntClass.NaryRestriction<O extends OntObject, P extends OntRelationalProperty>, OntClass.ObjectAllValuesFrom, OntClass.ObjectCardinality, OntClass.ObjectHasValue, OntClass.ObjectMaxCardinality, OntClass.ObjectMinCardinality, OntClass.ObjectSomeValuesFrom, OntClass.OneOf, OntClass.Restriction, OntClass.UnaryRestriction<P extends OntRelationalProperty>, OntClass.UnionOf, OntClass.ValueRestriction<O extends org.apache.jena.rdf.model.RDFNode, P extends OntRelationalProperty> -
Field Summary
Fields inherited from class org.apache.jena.rdf.model.impl.ResourceImpl
factory, rdfNodeFactory
-
Constructor Summary
ConstructorsConstructorDescriptionOntSimpleClassImpl
(org.apache.jena.graph.Node n, org.apache.jena.enhanced.EnhGraph eg) -
Method Summary
Modifier and TypeMethodDescriptionaddDisjointClass
(OntClass other) Adds the given class as a disjoint class and returns this class expression instance to allow cascading calls.addDisjointWithStatement
(OntClass other) Adds the given class as a disjoint class and returns the corresponding statement to provide the ability to add annotations.Adds the given class as an equivalent class and returns the corresponding statement to provide the ability to add annotations.addHasKeyStatement
(OntRelationalProperty... properties) Creates aHasKey
logical construction asontology list
and returns the statementC owl:hasKey ( P1 ... Pm R1 ... Rn )
to allow the subsequent addition of annotations.createHasKey
(Collection<OntObjectProperty> ope, Collection<OntDataProperty> dpe) Creates aHasKey
logical construction asontology []-list
ofObject or Data Property Expression
s that is attached to this Class Expression using the predicateowl:hasKey
.Creates an anonymous individual which is of this class-expression type.createIndividual
(String uri) Creates a named individual which is of this class type.declaredProperties
(boolean direct) Returns aStream
over theproperties
associated with a frame-like view of this class.Returns disjoint class-objects.Lists all equivalent classes.Finds the first declaration root statement.default <X extends org.apache.jena.rdf.model.RDFNode>
XSafely converts this RDF resource to the giventype
interface, if it is possible.getModel()
Returns the ontology model associated with this resource.boolean
hasDeclaredProperty
(OntProperty property, boolean direct) Returnstrue
if the given property is associated with a frame-like view of this class.hasKeys()
Lists allHasKey
ontology []-list
s that are attached to this class expression on predicateowl:hasKey
.boolean
hasSuperClass
(OntClass clazz, boolean direct) Answerstrue
if the given class is a superclass of this class.individuals
(boolean direct) Lists all individuals, directly or indirectly connected to this class.boolean
isDisjoint
(org.apache.jena.rdf.model.Resource candidate) Answerstrue
if this class is disjoint with the given class.boolean
Answers true if this class is one of the roots of the local class hierarchy.boolean
isLocal()
Determines if this Ontology Resource is locally defined.Gets a public ont-object type identifier.removeDisjointClass
(org.apache.jena.rdf.model.Resource other) Removes the specified disjoint class resource.removeEquivalentClass
(org.apache.jena.rdf.model.Resource other) Removes the given equivalent class resource including the statement's annotations.removeHasKey
(org.apache.jena.rdf.model.Resource list) Deletes the givenHasKey
list including its annotations.subClasses
(boolean direct) Answers aStream
over all the class expressions that are declared to be subclasses of this class expression.superClasses
(boolean direct) Answers aStream
over the class-expressions for which this class expression is declared a subclass.Methods inherited from class org.apache.jena.ontapi.impl.objects.OntObjectImpl
addAnnotation, addStatement, annotations, annotationValues, assertions, checkNamed, checkNamed, clearAnnotations, content, findActualClass, findActualClass, getAs, getMainStatement, getModel, getNodeAs, getRequiredObject, getRequiredProperty, isLocal, isReservedOrBuiltin, listAnnotationLiterals, listAnnotations, listAssertions, listObjects, listObjects, listProperties, listProperties, listSpec, listStatements, listStatements, listSubjects, object, objects, objects, remove, spec, statement, statement, statements, statements, subjects, toString, wrapAsOntObject
Methods inherited from class org.apache.jena.rdf.model.impl.ResourceImpl
abort, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addLiteral, addProperty, addProperty, addProperty, addProperty, addProperty, addProperty, addProperty, asLiteral, asResource, begin, commit, getId, getLocalName, getNameSpace, getProperty, getProperty, getPropertyResourceValue, getRequiredProperty, getStmtTerm, getURI, hasLiteral, hasLiteral, hasLiteral, hasLiteral, hasLiteral, hasLiteral, hasProperty, hasProperty, hasProperty, hasProperty, hasURI, inModel, listProperties, removeAll, removeProperties, visitWith
Methods inherited from class org.apache.jena.enhanced.EnhNode
as, asNode, canAs, equals, getGraph, hashCode, isAnon, isLiteral, isResource, isStmtResource, isURIResource, isValid, viewAs
Methods inherited from class org.apache.jena.enhanced.Polymorphic
addView, supports
Methods inherited from interface org.apache.jena.graph.FrontsNode
asNode
Methods inherited from interface org.apache.jena.ontapi.model.OntClass
addEquivalentClass, addHasKey, addHasKey, addHasKeyStatement, addSubClass, addSubClassOfStatement, addSuperClass, asAssertionClass, asDisjointClass, asEquivalentClass, asNamed, asSubClass, asSuperClass, canAsAssertionClass, canAsDisjointClass, canAsEquivalentClass, canAsSubClass, canAsSuperClass, clearHasKeys, declaredProperties, disjoints, findHasKey, fromHasKey, hasSubClass, individuals, properties, removeIndividual, removeSubClass, removeSuperClass, subClass, subClasses, superClass, superClasses
Methods inherited from interface org.apache.jena.ontapi.model.OntObject
addAnnotation, addAnnotation, addAnnotation, addComment, addComment, addLabel, addLabel, addStatement, annotate, annotate, annotations, annotationValues, annotationValues, clearAnnotations, content, getComment, getComment, getLabel, getLabel, getMainStatement, getRequiredProperty, hasType, objects, objects, remove, spec, statement, statement, statements, statements, types
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
-
Constructor Details
-
OntSimpleClassImpl
public OntSimpleClassImpl(org.apache.jena.graph.Node n, org.apache.jena.enhanced.EnhGraph eg)
-
-
Method Details
-
findRootStatement
Description copied from class:OntObjectImpl
Finds the first declaration root statement. The graph may contain several triples with predicaterdf:type
and this ontology object as a subject. In this case, the result is unpredictable.- Overrides:
findRootStatement
in classOntObjectImpl
- Returns:
- Optional around
OntStatement
that supports plain annotation assertions
-
objectType
Description copied from class:OntObjectImpl
Gets a public ont-object type identifier.- Specified by:
objectType
in interfaceOntObject
- Overrides:
objectType
in classOntObjectImpl
- Returns:
- Class, the actual type of this object
-
createIndividual
Description copied from interface:OntClass
Creates an anonymous individual which is of this class-expression type.- Specified by:
createIndividual
in interfaceOntClass
- Returns:
OntIndividual.Anonymous
- See Also:
-
createIndividual
Description copied from interface:OntClass
Creates a named individual which is of this class type.- Specified by:
createIndividual
in interfaceOntClass
- Parameters:
uri
- String, notnull
- Returns:
OntIndividual.Named
- See Also:
-
superClasses
Description copied from interface:OntClass
Answers aStream
over the class-expressions for which this class expression is declared a subclass. The returnStream
is distinct and this instance is not included in it.The flag
direct
allows some selectivity over the classes that appear in theStream
. Consider the following scenario:
(so:A rdfs:subClassOf :B . :A rdfs:subClassOf :C . :C rdfs:subClassOf :D .
A
has superclassesB
andC
, andC
has superclassD
) In a raw model, with no inference support, listing the superclasses ofA
will answerB
andC
. In an inferencing model,rdfs:subClassOf
is known to be transitive, so the superclasses iterator will includeD
. Thedirect
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 ofA
areB
andC
only, and notD
- 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:
Now, in the raw graph,:A rdfs:subClassOf :D .
A
has superclassesB
,C
,D
. But the direct superclasses ofA
remain onlyB
and C, since there is a longer pathA-C-D
that means thatD
is not a direct superclass ofA
. The assertion in the raw graph thatA
has superclassD
is essentially redundant, since this can be inferred from the closure of the graph.- Specified by:
superClasses
in interfaceOntClass
- Parameters:
direct
-boolean
: iftrue
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; iffalse
answers all superclasses found by inferencer, which usually means entire hierarchy up the tree; this class is not included- Returns:
- distinct
Stream
of superclass expression
s - See Also:
-
subClasses
Description copied from interface:OntClass
Answers aStream
over all the class expressions that are declared to be subclasses of this class expression. The returnStream
is distinct and this instance is not included in it. The flagdirect
allows some selectivity over the classes that appear in theStream
. Consider the following scenario:
(so:B rdfs:subClassOf :A. :C rdfs:subClassOf :A. :D rdfs:subClassOf :C.
A
has two subclasses,B
andC
, andC
has subclassD
) In a raw model, with no inference support, listing the subclasses ofA
will answerB
andC
. In an inferencing model,rdfs:subClassOf
is known to be transitive, so the subclasses iterator will includeD
. Thedirect
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 ofA
areB
andC
only, and notD
- 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:
Now, in the raw graph,:D rdfs:subClassOf :A.
A
has subclassC
. But the direct subclasses ofA
remainB
andC
, since there is a longer pathA-C-D
that means thatD
is not a direct subclass ofA
. The assertion in the raw graph thatA
has subclassD
is essentially redundant, since this can be inferred from the closure of the graph.- Specified by:
subClasses
in interfaceOntClass
- Parameters:
direct
-boolean
- iftrue
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; iffalse
answers all subclasses found by inferencer, which usually means entire hierarchy down the tree; this class is not included- Returns:
- distinct
Stream
of subclass expression
s - See Also:
-
individuals
Description copied from interface:OntClass
Lists all individuals, directly or indirectly connected to this class. The search pattern isa rdf:type C
, whereC
is class expression anda
individual.- Specified by:
individuals
in interfaceOntClass
- Parameters:
direct
-boolean
if true, only direct instances are counted (i.e., not instances of subclasses of this class)- Returns:
- a
Stream
ofOntIndividual
s
-
hasDeclaredProperty
Description copied from interface:OntClass
Returnstrue
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 interfaceOntClass
- Parameters:
property
-OntProperty
, notnull
direct
-boolean
: iftrue
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, otherwisefalse
-
declaredProperties
Description copied from interface:OntClass
Returns aStream
over theproperties
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'sOntModel
with the class itself. See: Apache Jena: Presenting RDF as frames for more details.- Specified by:
declaredProperties
in interfaceOntClass
- Parameters:
direct
-boolean
: iftrue
analyses only the directly adjacent domains in the subclass relation, otherwise takes into account the class hierarchy- Returns:
- a distinct
Stream
ofobject, 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 eitherowl:Thing
orrdfs:Resource
as a direct superclass, or (ii) it has no declared superclasses.owl:Nothing
cannot be root.- Specified by:
isHierarchyRoot
in interfaceOntClass
- Returns:
true
if this class is the root of the class hierarchy in the model it is attached to
-
createHasKey
public OntList<OntRelationalProperty> createHasKey(Collection<OntObjectProperty> ope, Collection<OntDataProperty> dpe) Description copied from interface:OntClass
Creates aHasKey
logical construction asontology []-list
ofObject or Data Property Expression
s that is attached to this Class Expression using the predicateowl: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:null
s in the collection will causeexception
. For additional information aboutHasKey
logical construction see 9.5 Keys specification.- Specified by:
createHasKey
in interfaceOntClass
- Parameters:
ope
-Collection
(preferablySet
) ofobject property expression
sdpe
-Collection
(preferablySet
) ofdata property expression
s- Returns:
OntList
ofOntRelationalProperty
s- See Also:
-
addHasKeyStatement
Description copied from interface:OntClass
Creates aHasKey
logical construction asontology list
and returns the statementC 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 interfaceOntClass
- Parameters:
properties
- Array ofOntRelationalProperty
s withoutnull
s- Returns:
OntStatement
with a possibility to annotate- See Also:
-
hasKeys
Description copied from interface:OntClass
Lists allHasKey
ontology []-list
s that are attached to this class expression on predicateowl:hasKey
. -
removeHasKey
public OntSimpleClassImpl removeHasKey(org.apache.jena.rdf.model.Resource list) throws OntJenaException.IllegalArgument Description copied from interface:OntClass
Deletes the givenHasKey
list including its annotations.- Specified by:
removeHasKey
in interfaceOntClass
- Parameters:
list
-Resource
can beOntList
orRDFList
; ifnull
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
Answerstrue
if this class is disjoint with the given class.- Specified by:
isDisjoint
in interfaceOntClass
- Parameters:
candidate
-Resource
a class to test- Returns:
true
if this class is disjoint with the given class
-
disjointClasses
Description copied from interface:OntClass
Returns disjoint class-objects. This includesthisClass owl:disjointWith otherClass
,otherClass owl:disjointWith thisClass
statements andowl:AllDisjointClasses
construct.- Specified by:
disjointClasses
in interfaceOntClass
- Returns:
- a
Stream
ofOntClass
s - See Also:
-
equivalentClasses
Description copied from interface:OntClass
Lists all equivalent classes. The statement patter to search for isC1 owl:equivalentClass C2
.- Specified by:
equivalentClasses
in interfaceOntClass
- Returns:
Stream
ofOntClass
s- See Also:
-
hasSuperClass
Description copied from interface:OntClass
Answerstrue
if the given class is a superclass of this class. SeeOntClass.superClasses(boolean)
for a full explanation of the direct parameter- Specified by:
hasSuperClass
in interfaceOntClass
- Parameters:
clazz
- aOntClass
to testdirect
-boolean
; If true, only search the classes that are directly adjacent to this class in the class hierarchy.- Returns:
boolean
-
addDisjointClass
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 interfaceOntClass
- Parameters:
other
-OntClass
, notnull
- Returns:
- this instance to allow cascading calls
- See Also:
-
addDisjointWithStatement
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 interfaceOntClass
- Parameters:
other
-OntClass
, notnull
- Returns:
OntStatement
to allow the subsequent annotations addition- See Also:
-
removeDisjointClass
Description copied from interface:OntClass
Removes the specified disjoint class resource. No-op in case no match found. Removes allowl:disjointWith
statements with all their annotations in casenull
is specified.- Specified by:
removeDisjointClass
in interfaceOntClass
- Parameters:
other
-Resource
, ornull
to remove all disjoint classes- Returns:
- this instance to allow cascading calls
- See Also:
-
addEquivalentClassStatement
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 interfaceOntClass
- Parameters:
other
-OntClass
, notnull
- Returns:
OntStatement
to allow the subsequent annotations addition- See Also:
-
removeEquivalentClass
Description copied from interface:OntClass
Removes the given equivalent class resource including the statement's annotations. No-op in case no match found. Removes allowl:equivalentClass
statements with all their annotations in casenull
is specified.- Specified by:
removeEquivalentClass
in interfaceOntClass
- Parameters:
other
-Resource
, ornull
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 interfaceorg.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 theroot statement
) belongs to the base ontology graph. If the ontology contains subgraphs (which should matchowl:imports
in OWL) and the resource is defined in one of them, than this method called from top-level interface will returnfalse
.- Returns:
true
if this resource is local to the base model graph.
-
getAs
Safely converts this RDF resource to the giventype
interface, if it is possible. Otherwise, returnsnull
. A calling of this method is effectively equivalent to the expressionthis.canAs(type) ? this.as(type) : null
.- Type Parameters:
X
- any subtype ofRDFNode
- Parameters:
type
- aClass
-type of the desired RDF view (interface)- Returns:
- an instance of the type
X
ornull
- See Also:
-
RDFNode.as(Class)
RDFNode.canAs(Class)
-