- All Implemented Interfaces:
org.apache.jena.graph.FrontsNode,OntObject,org.apache.jena.rdf.model.RDFNode,org.apache.jena.rdf.model.Resource
- Direct Known Subclasses:
OntAnnotationImpl,OntClassImpl,OntDataRangeImpl,OntDisjointImpl,OntFacetRestrictionImpl,OntIDImpl,OntIndividualImpl,OntNamedDataRangeImpl,OntNegativePropertyAssertionImpl,OntPropertyImpl,OntSimpleClassImpl,OntSWRLImpl,OntSWRLImpl.DArgImpl,OntSWRLImpl.IArgImpl
Resource implementation.-
Field Summary
Fields inherited from class org.apache.jena.rdf.model.impl.ResourceImpl
factory, rdfNodeFactory -
Constructor Summary
ConstructorsConstructorDescriptionOntObjectImpl(org.apache.jena.graph.Node n, org.apache.jena.enhanced.EnhGraph m) -
Method Summary
Modifier and TypeMethodDescriptionaddAnnotation(OntAnnotationProperty property, org.apache.jena.rdf.model.RDFNode value) Adds an annotation assertion.addStatement(org.apache.jena.rdf.model.Property property, org.apache.jena.rdf.model.RDFNode value) Adds an ont-statement by attaching predicate and object (value) to this resource.Lists all annotation property assertions (so-called plain annotations) attached to this object plus all bulk annotations of the root statement.annotationValues(OntAnnotationProperty p, String lang) Lists all annotation literals for the given predicate and the language tag.Lists all annotation property assertions (so-called plain annotations) attached to this object.static org.apache.jena.graph.NodecheckNamed(org.apache.jena.graph.Node res) Tests the node is named.static org.apache.jena.rdf.model.ResourcecheckNamed(org.apache.jena.rdf.model.Resource res) Tests the RDF resource is named.Removes all root annotations including their sub-annotations hierarchy.content()Lists the content of the object, i.e., all characteristic statements (seeOntObject.spec()), plus all additional statements in which this object is the subject, minus those of them whose predicate is an annotation property (annotations are not included).findActualClass(Class<? extends OntObject> type) Finds a publicOntology Objectclass-type.Finds the first declaration root statement.<X extends org.apache.jena.rdf.model.RDFNode>
XSafely converts this RDF resource to the giventypeinterface, if it is possible.final OntStatementReturns the mainOntStatementwhich determines the nature of this ontological resource.getModel()static <X extends org.apache.jena.rdf.model.RDFNode>
XAnswers an enhanced node that wraps the given RDF node and conforms to the given interfaceview.<T extends org.apache.jena.rdf.model.RDFNode>
TgetRequiredObject(org.apache.jena.rdf.model.Property predicate, Class<T> view) Returns an object from a first found statement with specified predicate.getRequiredProperty(org.apache.jena.rdf.model.Property property) Returns an ont-statement with the given subject and property.booleanisLocal()static booleanisReservedOrBuiltin(OntObject object) Returnstrueif the given object is from reserved vocabulary (e.g.org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.rdf.model.Literal>listAnnotationLiterals(OntAnnotationProperty predicate) Returns an iterator over all literal's annotations.org.apache.jena.util.iterator.ExtendedIterator<OntStatement>Lists all related annotation assertions.org.apache.jena.util.iterator.ExtendedIterator<OntStatement>Returns an iterator over object's annotation property assertions.org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.rdf.model.RDFNode>listObjects(org.apache.jena.rdf.model.Property predicate) Lists all objects for the given predicate.<O extends org.apache.jena.rdf.model.RDFNode>
org.apache.jena.util.iterator.ExtendedIterator<O>listObjects(org.apache.jena.rdf.model.Property predicate, Class<O> type) Lists all objects for the given predicate and type, considering this instance in a subject relation.org.apache.jena.rdf.model.StmtIteratororg.apache.jena.rdf.model.StmtIteratorlistProperties(org.apache.jena.rdf.model.Property p) org.apache.jena.util.iterator.ExtendedIterator<OntStatement>listSpec()Lists all object's characteristic statements according to its OWL2 specification.org.apache.jena.util.iterator.ExtendedIterator<OntStatement>Returns anExtended Iteratorover all the properties of this resource.org.apache.jena.util.iterator.ExtendedIterator<OntStatement>listStatements(org.apache.jena.rdf.model.Property p) Lists all the values of the propertyp.<S extends org.apache.jena.rdf.model.RDFNode>
org.apache.jena.util.iterator.ExtendedIterator<S>listSubjects(org.apache.jena.rdf.model.Property predicate, Class<S> type) Lists all subjects for the given predicate and type, considering this instance in an object relation.<T extends org.apache.jena.rdf.model.RDFNode>
Optional<T>Finds a first object with the givenrdf:typeattached to this ontology object on the givenpredicate.Stream<org.apache.jena.rdf.model.RDFNode>objects(org.apache.jena.rdf.model.Property predicate) Lists all objects for the given predicate.<O extends org.apache.jena.rdf.model.RDFNode>
Stream<O>Lists all objects attached on the property to this object with the given type.Gets a public ont-object type identifier.remove(org.apache.jena.rdf.model.Property property, org.apache.jena.rdf.model.RDFNode value) Deletes the specific property-value pair from this object.spec()Lists all characteristic statements of the ontology resource, i.e., all those statements which completely determine this object nature according to the OWL2 specification.statement(org.apache.jena.rdf.model.Property property) Returns the first statement for the specified property.statement(org.apache.jena.rdf.model.Property property, org.apache.jena.rdf.model.RDFNode value) Returns the first statement for the specified property and object.Lists all top-level statements related to this object (i.e., with subject=this).statements(org.apache.jena.rdf.model.Property property) Lists ont-statements by the predicate.toString()static OntObjectwrapAsOntObject(org.apache.jena.graph.Node node, org.apache.jena.enhanced.EnhGraph model) Creates a freshOntObjectinstance.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, 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.OntObject
addAnnotation, addAnnotation, addComment, addComment, addLabel, addLabel, annotate, annotate, annotationValues, getComment, getComment, getLabel, getLabel, hasType, 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, removeAll, removeProperties
-
Constructor Details
-
OntObjectImpl
public OntObjectImpl(org.apache.jena.graph.Node n, org.apache.jena.enhanced.EnhGraph m)
-
-
Method Details
-
checkNamed
public static org.apache.jena.graph.Node checkNamed(org.apache.jena.graph.Node res) Tests the node is named.- Parameters:
res-Nodeto test, notnull- Returns:
- the same node
- Throws:
OntJenaException- in casenullor anonymous node is given
-
checkNamed
public static org.apache.jena.rdf.model.Resource checkNamed(org.apache.jena.rdf.model.Resource res) Tests the RDF resource is named.- Parameters:
res-Resourceto test, notnull- Returns:
- the same resource
- Throws:
OntJenaException- in casenullor anonymous resource is given
-
subjects
-
findActualClass
Finds a publicOntology Objectclass-type. -
findActualClass
-
getNodeAs
public static <X extends org.apache.jena.rdf.model.RDFNode> X getNodeAs(org.apache.jena.rdf.model.RDFNode node, Class<X> view) Answers an enhanced node that wraps the given RDF node and conforms to the given interfaceview. The method does not change the model nodes cache, but changes the object's cache ifviewis suitable for the given node.- Type Parameters:
X- any subtype ofRDFNode- Parameters:
node-RDFNode, notnullview- aClass-type of the desired RDF view (interface)- Returns:
- an instance of the type
Xornull - See Also:
-
wrapAsOntObject
public static OntObject wrapAsOntObject(org.apache.jena.graph.Node node, org.apache.jena.enhanced.EnhGraph model) Creates a freshOntObjectinstance.- Parameters:
node-Node, notnullmodel-EnhGraph, notnull- Returns:
OntObject
-
isReservedOrBuiltin
Returnstrueif the given object is from reserved vocabulary (e.g.rdf:restis reserved in system settings).- Parameters:
object-OntObject- Returns:
- boolean
-
isLocal
public boolean isLocal()- Returns:
trueif the root statement belongs to the base graph
-
getMainStatement
Returns the mainOntStatementwhich determines the nature of this ontological resource. In most cases it is a declaration and wraps a triple with predicaterdf:type.The returned
OntStatementdiffers from that which could be obtained directly from the model using one of model'sstatement(..)methods: the main statement annotations are added in the form of annotation property assertions (so-called 'plain annotations'), not as typed anonymous resources (so-called 'bulk annotations',OntAnnotation). In ONT-API it is legal for a main statement to have both plain and bulk annotations. Note: for anonymous ontology objects (i.e., not for OWL Entities) this behavior may not fully meet OWL2 specification: the specification describes only bulk annotations for all anonymous OWL2 components with except of an individual. To get a common ontology statement that supports bulk annotations only, the expressiongetModel().asStatement(this.getMainStatement().asTriple())can be used.- Specified by:
getMainStatementin interfaceOntObject- Returns:
OntStatement- See Also:
-
spec
Lists all characteristic statements of the ontology resource, i.e., all those statements which completely determine this object nature according to the OWL2 specification. For non-composite objects the result might contain only theroot statement. For composite objects (usually anonymous resources: disjoint sections, class expression, etc.) the result would contain all statements in the graph directly related to the object but without statements that relate to the object components. The return stream is ordered and, in most cases, the expressionthis.spec().findFirst().get()returns the same statement asthis.getRoot(). Object annotations are not included in the resultant stream.For OWL Entities the returned stream will contain only a single main statement (i.e.
OntObject.getMainStatement()), or even will be empty for built-in entities and individuals.- Specified by:
specin interfaceOntObject- Returns:
- Stream of
OntStatements - See Also:
-
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.Impl remarks: - the method body is optimized to minimize graph querying; - we use
RDFNode(notResource) as generic supertype due to the fact that anOntObjectcan be also aLiteral(but in only single case when it isOntSWRL.DArg). -
listSpec
Lists all object's characteristic statements according to its OWL2 specification.- Returns:
ExtendedIteratorofOntStatements
-
content
Lists the content of the object, i.e., all characteristic statements (seeOntObject.spec()), plus all additional statements in which this object is the subject, minus those of them whose predicate is an annotation property (annotations are not included).- Specified by:
contentin interfaceOntObject- Returns:
- distinct Stream of
OntStatements - See Also:
-
findRootStatement
Finds 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.- Returns:
- Optional around
OntStatementthat supports plain annotation assertions
-
statement
Returns the first statement for the specified property. What is the first triple is defined at the level of graph; in general, it is unpredictable.- Specified by:
statementin interfaceOntObject- Parameters:
property-Property- Returns:
- Optional around
OntStatement - See Also:
-
Resource.getProperty(Property)
-
statement
public Optional<OntStatement> statement(org.apache.jena.rdf.model.Property property, org.apache.jena.rdf.model.RDFNode value) Returns the first statement for the specified property and object. What exactly is the first triple is defined at the level of graph; in general, it is unpredictable. Also note, the common jena implementation of in-memory graph does not allow duplicated triples, and hence there can be at most one operator for a givenpropertyandvalue.- Specified by:
statementin interfaceOntObject- Parameters:
property-Property, the predicatevalue-RDFNode, the object- Returns:
- Optional around
OntStatement
-
getRequiredProperty
public OntStatement getRequiredProperty(org.apache.jena.rdf.model.Property property) throws org.apache.jena.shared.PropertyNotFoundException Returns an ont-statement with the given subject and property. If more than one statement that matches the patter exists in the model, it is undefined which will be returned. If none exist, an exception is thrown.- Specified by:
getRequiredPropertyin interfaceOntObject- Specified by:
getRequiredPropertyin interfaceorg.apache.jena.rdf.model.Resource- Overrides:
getRequiredPropertyin classorg.apache.jena.rdf.model.impl.ResourceImpl- Parameters:
property-Property, the predicate- Returns:
OntStatement- Throws:
org.apache.jena.shared.PropertyNotFoundException- no statement is found- See Also:
-
Resource.getRequiredProperty(Property)
-
addStatement
public OntStatement addStatement(org.apache.jena.rdf.model.Property property, org.apache.jena.rdf.model.RDFNode value) Description copied from interface:OntObjectAdds an ont-statement by attaching predicate and object (value) to this resource.- Specified by:
addStatementin interfaceOntObject- Parameters:
property-Propertypredicate, notnullvalue-RDFNodeobject, notnull- Returns:
OntStatement- See Also:
-
Resource.addProperty(Property, RDFNode)
-
remove
public OntObjectImpl remove(org.apache.jena.rdf.model.Property property, org.apache.jena.rdf.model.RDFNode value) Description copied from interface:OntObjectDeletes the specific property-value pair from this object. All the corresponding statement's annotations are also deleted. In case the givenobjectisnull, all statements with theproperty-predicate will be deleted. No-op if no match found. -
statements
Description copied from interface:OntObjectLists ont-statements by the predicate.- Specified by:
statementsin interfaceOntObject- Parameters:
property-Property, predicate, can benull- Returns:
StreamofOntStatements
-
statements
Description copied from interface:OntObjectLists all top-level statements related to this object (i.e., with subject=this).- Specified by:
statementsin interfaceOntObject- Returns:
Streamof all statements- See Also:
-
Resource.listProperties()
-
listProperties
public org.apache.jena.rdf.model.StmtIterator listProperties()- Specified by:
listPropertiesin interfaceorg.apache.jena.rdf.model.Resource- Overrides:
listPropertiesin classorg.apache.jena.rdf.model.impl.ResourceImpl- Returns:
StmtIteratorwhich containsOntStatements- See Also:
-
listStatements
Returns anExtended Iteratorover all the properties of this resource. The model associated with this resource is search and an iterator is returned which iterates over all the statements which have this resource as a subject.- Returns:
ExtendedIteratorover all theOntStatements about this object- See Also:
-
listProperties
public org.apache.jena.rdf.model.StmtIterator listProperties(org.apache.jena.rdf.model.Property p) - Specified by:
listPropertiesin interfaceorg.apache.jena.rdf.model.Resource- Overrides:
listPropertiesin classorg.apache.jena.rdf.model.impl.ResourceImpl- Parameters:
p-Property, the predicate to search, can benull- Returns:
StmtIterator- See Also:
-
listStatements
public org.apache.jena.util.iterator.ExtendedIterator<OntStatement> listStatements(org.apache.jena.rdf.model.Property p) Lists all the values of the propertyp. Returns anExtended Iteratorover all the statements in the associated model whose subject is this resource and whose predicate isp.- Parameters:
p-Property, the predicate sought, can benull- Returns:
ExtendedIteratorover theOntStatements- See Also:
-
annotations
Lists all annotation property assertions (so-called plain annotations) attached to this object plus all bulk annotations of the root statement.- Specified by:
annotationsin interfaceOntObject- Returns:
- Stream of
OntStatements - See Also:
-
listAnnotations
Lists all related annotation assertions.- Returns:
ExtendedIteratorofOntStatements- See Also:
-
assertions
Lists all annotation property assertions (so-called plain annotations) attached to this object.- Returns:
- Stream of
OntStatements - See Also:
-
listAssertions
Returns an iterator over object's annotation property assertions. The annotation assertion is a statements with anannotation propertyas predicate.- Returns:
ExtendedIteratorofOntStatements- See Also:
-
listAnnotationLiterals
public org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.rdf.model.Literal> listAnnotationLiterals(OntAnnotationProperty predicate) Returns an iterator over all literal's annotations.- Parameters:
predicate-OntAnnotationProperty, notnull- Returns:
ExtendedIteratorofLiterals- See Also:
-
annotationValues
Description copied from interface:OntObjectLists all annotation literals for the given predicate and the language tag. Literal tag comparison is case-insensitive. Partial search is also allowed, for example, a literal with the tagen-GBwill list also if the input language tag isen. An empty string as language tag means searching for plain no-language literals.- Specified by:
annotationValuesin interfaceOntObject- Parameters:
p-OntAnnotationProperty, notnulllang- String, the language tag to restrict the listed literals to, ornullto select all literals- Returns:
Streamof String's, i.e., literal lexical forms- See Also:
-
addAnnotation
public OntStatement addAnnotation(OntAnnotationProperty property, org.apache.jena.rdf.model.RDFNode value) Adds an annotation assertion. It could be expanded to a bulk form by adding sub-annotation.- Specified by:
addAnnotationin interfaceOntObject- Parameters:
property-OntAnnotationProperty, Named annotation property.value-RDFNodethe value: uri-resource, literal or anonymous individual.- Returns:
- OntStatement for newly added annotation
- Throws:
OntJenaException- in case input is wrong- See Also:
-
clearAnnotations
Removes all root annotations including their sub-annotations hierarchy. Any non-root annotations are untouched. For example, in case of deleting an OWL class, if it is present on the left side of therdfs:subClassOfstatement, all the annotations of that statement will remain in the graph, but all main annotations (which belongs to the statement with the predicaterdf:type) will be deleted from the graph. For non-built-in ontology objects this is equivalent to the expressiongetRoot().clearAnnotations().- Specified by:
clearAnnotationsin interfaceOntObject- Returns:
- this instance
- See Also:
-
getRequiredObject
public <T extends org.apache.jena.rdf.model.RDFNode> T getRequiredObject(org.apache.jena.rdf.model.Property predicate, Class<T> view) Returns an object from a first found statement with specified predicate. Since the order in the graph is undefined in case there is more than one statement for a property, the result is unpredictable.- Type Parameters:
T-RDFNodetype- Parameters:
predicate-Propertyview- Class- Returns:
- an object from statement
- Throws:
OntJenaException- in case no object by predicate has been found- See Also:
-
object
public <T extends org.apache.jena.rdf.model.RDFNode> Optional<T> object(org.apache.jena.rdf.model.Property predicate, Class<T> type) Finds a first object with the givenrdf:typeattached to this ontology object on the givenpredicate. The result is unpredictable in case there more than one statement for these conditions.- Type Parameters:
T- any subtype ofRDFNode- Parameters:
predicate-Propertytype- subclass ofRDFNode- Returns:
- Optional around
T
-
objects
public <O extends org.apache.jena.rdf.model.RDFNode> Stream<O> objects(org.apache.jena.rdf.model.Property predicate, Class<O> type) Lists all objects attached on the property to this object with the given type. -
listObjects
public <O extends org.apache.jena.rdf.model.RDFNode> org.apache.jena.util.iterator.ExtendedIterator<O> listObjects(org.apache.jena.rdf.model.Property predicate, Class<O> type) Lists all objects for the given predicate and type, considering this instance in a subject relation.- Type Parameters:
O- subtype ofrdf-node- Parameters:
predicate-Property, can benulltype- class-type of interface to find and cast, notnull- Returns:
ExtendedIteratorofnodes of the typeO- See Also:
-
listSubjects
public <S extends org.apache.jena.rdf.model.RDFNode> org.apache.jena.util.iterator.ExtendedIterator<S> listSubjects(org.apache.jena.rdf.model.Property predicate, Class<S> type) Lists all subjects for the given predicate and type, considering this instance in an object relation.- Type Parameters:
S- subtype ofrdf-node- Parameters:
predicate-Property, can benulltype- class-type of interface to find and cast, notnull- Returns:
ExtendedIteratorofnodes of the typeS- See Also:
-
objects
public Stream<org.apache.jena.rdf.model.RDFNode> objects(org.apache.jena.rdf.model.Property predicate) Lists all objects for the given predicate. -
listObjects
public org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.rdf.model.RDFNode> listObjects(org.apache.jena.rdf.model.Property predicate) Lists all objects for the given predicate.- Parameters:
predicate-Property- Returns:
ExtendedIteratorofRDFNodes- See Also:
-
getModel
- Specified by:
getModelin interfaceorg.apache.jena.rdf.model.RDFNode- Overrides:
getModelin classorg.apache.jena.rdf.model.impl.ResourceImpl
-
objectType
Gets a public ont-object type identifier.- Specified by:
objectTypein interfaceOntObject- Returns:
- Class, the actual type of this object
-
toString
- Specified by:
toStringin interfaceorg.apache.jena.rdf.model.RDFNode- Specified by:
toStringin interfaceorg.apache.jena.rdf.model.Resource- Overrides:
toStringin classorg.apache.jena.rdf.model.impl.ResourceImpl
-