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 classPrimary (named) class (<uri> a owl:Class).static classA 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 aHasKeylogical construction asontology listand returns the statementC owl:hasKey ( P1 ... Pm R1 ... Rn )to allow the subsequent addition of annotations.createHasKey(Collection<OntObjectProperty> ope, Collection<OntDataProperty> dpe) Creates aHasKeylogical construction asontology []-listofObject or Data Property Expressions 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 aStreamover thepropertiesassociated 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 giventypeinterface, if it is possible.getModel()Returns the ontology model associated with this resource.booleanhasDeclaredProperty(OntProperty property, boolean direct) Returnstrueif the given property is associated with a frame-like view of this class.hasKeys()Lists allHasKeyontology []-lists that are attached to this class expression on predicateowl:hasKey.booleanhasSuperClass(OntClass clazz, boolean direct) Answerstrueif the given class is a superclass of this class.individuals(boolean direct) Lists all individuals, directly or indirectly connected to this class.booleanisDisjoint(org.apache.jena.rdf.model.Resource candidate) Answerstrueif this class is disjoint with the given class.booleanAnswers true if this class is one of the roots of the local class hierarchy.booleanisLocal()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 givenHasKeylist including its annotations.subClasses(boolean direct) Answers aStreamover all the class expressions that are declared to be subclasses of this class expression.superClasses(boolean direct) Answers aStreamover 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, wrapAsOntObjectMethods 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, asStatementTerm, begin, commit, getId, getLocalName, getNameSpace, getProperty, getProperty, getPropertyResourceValue, getRequiredProperty, getURI, hasLiteral, hasLiteral, hasLiteral, hasLiteral, hasLiteral, hasLiteral, hasProperty, hasProperty, hasProperty, hasProperty, hasURI, inModel, listProperties, removeAll, removeProperties, visitWithMethods inherited from class org.apache.jena.enhanced.EnhNode
as, asNode, canAs, equals, getGraph, hashCode, isAnon, isLiteral, isResource, isStatementTerm, isURIResource, isValid, viewAsMethods inherited from class org.apache.jena.enhanced.Polymorphic
addView, supportsMethods inherited from interface org.apache.jena.graph.FrontsNode
asNodeMethods 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, superClassesMethods 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, typesMethods inherited from interface org.apache.jena.rdf.model.RDFNode
as, asLiteral, asResource, asStatementTerm, canAs, isAnon, isLiteral, isResource, isStatementTerm, isURIResource, visitWithMethods 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, 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:OntObjectImplFinds the first declaration root statement. The graph may contain several triples with predicaterdf:typeand this ontology object as a subject. In this case, the result is unpredictable.- Overrides:
findRootStatementin classOntObjectImpl- Returns:
- Optional around
OntStatementthat supports plain annotation assertions
-
objectType
Description copied from class:OntObjectImplGets a public ont-object type identifier.- Specified by:
objectTypein interfaceOntObject- Overrides:
objectTypein classOntObjectImpl- Returns:
- Class, the actual type of this object
-
createIndividual
Description copied from interface:OntClassCreates an anonymous individual which is of this class-expression type.- Specified by:
createIndividualin interfaceOntClass- Returns:
OntIndividual.Anonymous- See Also:
-
createIndividual
Description copied from interface:OntClassCreates a named individual which is of this class type.- Specified by:
createIndividualin interfaceOntClass- Parameters:
uri- String, notnull- Returns:
OntIndividual.Named- See Also:
-
superClasses
Description copied from interface:OntClassAnswers aStreamover the class-expressions for which this class expression is declared a subclass. The returnStreamis distinct and this instance is not included in it.The flag
directallows 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 .Ahas superclassesBandC, andChas superclassD) In a raw model, with no inference support, listing the superclasses ofAwill answerBandC. In an inferencing model,rdfs:subClassOfis known to be transitive, so the superclasses iterator will includeD. Thedirectsuperclasses 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 ofAareBandConly, 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 .Ahas superclassesB,C,D. But the direct superclasses ofAremain onlyBand C, since there is a longer pathA-C-Dthat means thatDis not a direct superclass ofA. The assertion in the raw graph thatAhas superclassDis essentially redundant, since this can be inferred from the closure of the graph.- Specified by:
superClassesin interfaceOntClass- Parameters:
direct-boolean: iftrueanswers 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; iffalseanswers all superclasses found by inferencer, which usually means entire hierarchy up the tree; this class is not included- Returns:
- distinct
Streamof superclass expressions - See Also:
-
subClasses
Description copied from interface:OntClassAnswers aStreamover all the class expressions that are declared to be subclasses of this class expression. The returnStreamis distinct and this instance is not included in it. The flagdirectallows 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.Ahas two subclasses,BandC, andChas subclassD) In a raw model, with no inference support, listing the subclasses ofAwill answerBandC. In an inferencing model,rdfs:subClassOfis known to be transitive, so the subclasses iterator will includeD. Thedirectsubclasses 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 ofAareBandConly, 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.Ahas subclassC. But the direct subclasses ofAremainBandC, since there is a longer pathA-C-Dthat means thatDis not a direct subclass ofA. The assertion in the raw graph thatAhas subclassDis essentially redundant, since this can be inferred from the closure of the graph.- Specified by:
subClassesin interfaceOntClass- Parameters:
direct-boolean- iftrueanswers 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; iffalseanswers all subclasses found by inferencer, which usually means entire hierarchy down the tree; this class is not included- Returns:
- distinct
Streamof subclass expressions - See Also:
-
individuals
Description copied from interface:OntClassLists all individuals, directly or indirectly connected to this class. The search pattern isa rdf:type C, whereCis class expression andaindividual.- Specified by:
individualsin interfaceOntClass- Parameters:
direct-booleanif true, only direct instances are counted (i.e., not instances of subclasses of this class)- Returns:
- a
StreamofOntIndividuals
-
hasDeclaredProperty
Description copied from interface:OntClassReturnstrueif 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:
hasDeclaredPropertyin interfaceOntClass- Parameters:
property-OntProperty, notnulldirect-boolean: iftrueanalyses only the directly adjacent domains in the subclass relation, otherwise takes into account the class hierarchy- Returns:
boolean,trueif the property is associated with this class by its domain, otherwisefalse
-
declaredProperties
Description copied from interface:OntClassReturns aStreamover thepropertiesassociated 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'sOntModelwith the class itself. See: Apache Jena: Presenting RDF as frames for more details.- Specified by:
declaredPropertiesin interfaceOntClass- Parameters:
direct-boolean: iftrueanalyses only the directly adjacent domains in the subclass relation, otherwise takes into account the class hierarchy- Returns:
- a distinct
Streamofobject, datatype and annotation properties, attached to this class - See Also:
-
isHierarchyRoot
public boolean isHierarchyRoot()Description copied from interface:OntClassAnswers 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:Thingorrdfs:Resourceas a direct superclass, or (ii) it has no declared superclasses.owl:Nothingcannot be root.- Specified by:
isHierarchyRootin interfaceOntClass- Returns:
trueif 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:OntClassCreates aHasKeylogical construction asontology []-listofObject or Data Property Expressions 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:nulls in the collection will causeexception. For additional information aboutHasKeylogical construction see 9.5 Keys specification.- Specified by:
createHasKeyin interfaceOntClass- Parameters:
ope-Collection(preferablySet) ofobject property expressionsdpe-Collection(preferablySet) ofdata property expressions- Returns:
OntListofOntRelationalPropertys- See Also:
-
addHasKeyStatement
Description copied from interface:OntClassCreates aHasKeylogical construction asontology listand 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:
addHasKeyStatementin interfaceOntClass- Parameters:
properties- Array ofOntRelationalPropertys withoutnulls- Returns:
OntStatementwith a possibility to annotate- See Also:
-
hasKeys
Description copied from interface:OntClassLists allHasKeyontology []-lists 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:OntClassDeletes the givenHasKeylist including its annotations.- Specified by:
removeHasKeyin interfaceOntClass- Parameters:
list-Resourcecan beOntListorRDFList; ifnullthe 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:OntClassAnswerstrueif this class is disjoint with the given class.- Specified by:
isDisjointin interfaceOntClass- Parameters:
candidate-Resourcea class to test- Returns:
trueif this class is disjoint with the given class
-
disjointClasses
Description copied from interface:OntClassReturns disjoint class-objects. This includesthisClass owl:disjointWith otherClass,otherClass owl:disjointWith thisClassstatements andowl:AllDisjointClassesconstruct.- Specified by:
disjointClassesin interfaceOntClass- Returns:
- a
StreamofOntClasss - See Also:
-
equivalentClasses
Description copied from interface:OntClassLists all equivalent classes. The statement patter to search for isC1 owl:equivalentClass C2.- Specified by:
equivalentClassesin interfaceOntClass- Returns:
StreamofOntClasss- See Also:
-
hasSuperClass
Description copied from interface:OntClassAnswerstrueif the given class is a superclass of this class. SeeOntClass.superClasses(boolean)for a full explanation of the direct parameter- Specified by:
hasSuperClassin interfaceOntClass- Parameters:
clazz- aOntClassto 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:OntClassAdds the given class as a disjoint class and returns this class expression instance to allow cascading calls.- Specified by:
addDisjointClassin interfaceOntClass- Parameters:
other-OntClass, notnull- Returns:
- this instance to allow cascading calls
- See Also:
-
addDisjointWithStatement
Description copied from interface:OntClassAdds the given class as a disjoint class and returns the corresponding statement to provide the ability to add annotations.- Specified by:
addDisjointWithStatementin interfaceOntClass- Parameters:
other-OntClass, notnull- Returns:
OntStatementto allow the subsequent annotations addition- See Also:
-
removeDisjointClass
Description copied from interface:OntClassRemoves the specified disjoint class resource. No-op in case no match found. Removes allowl:disjointWithstatements with all their annotations in casenullis specified.- Specified by:
removeDisjointClassin interfaceOntClass- Parameters:
other-Resource, ornullto remove all disjoint classes- Returns:
- this instance to allow cascading calls
- See Also:
-
addEquivalentClassStatement
Description copied from interface:OntClassAdds the given class as an equivalent class and returns the corresponding statement to provide the ability to add annotations.- Specified by:
addEquivalentClassStatementin interfaceOntClass- Parameters:
other-OntClass, notnull- Returns:
OntStatementto allow the subsequent annotations addition- See Also:
-
removeEquivalentClass
Description copied from interface:OntClassRemoves the given equivalent class resource including the statement's annotations. No-op in case no match found. Removes allowl:equivalentClassstatements with all their annotations in casenullis specified.- Specified by:
removeEquivalentClassin interfaceOntClass- Parameters:
other-Resource, ornullto 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:
getModelin 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:importsin OWL) and the resource is defined in one of them, than this method called from top-level interface will returnfalse.- Returns:
trueif this resource is local to the base model graph.
-
getAs
Safely converts this RDF resource to the giventypeinterface, 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
Xornull - See Also:
-
RDFNode.as(Class)RDFNode.canAs(Class)
-