- 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.Node
checkNamed
(org.apache.jena.graph.Node res) Tests the node is named.static org.apache.jena.rdf.model.Resource
checkNamed
(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 Object
class-type.Finds the first declaration root statement.<X extends org.apache.jena.rdf.model.RDFNode>
XSafely converts this RDF resource to the giventype
interface, if it is possible.final OntStatement
Returns the mainOntStatement
which 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.boolean
isLocal()
static boolean
isReservedOrBuiltin
(OntObject object) Returnstrue
if 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.StmtIterator
org.apache.jena.rdf.model.StmtIterator
listProperties
(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 Iterator
over 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:type
attached 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 OntObject
wrapAsOntObject
(org.apache.jena.graph.Node node, org.apache.jena.enhanced.EnhGraph model) Creates a freshOntObject
instance.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.OntObject
addAnnotation, addAnnotation, addComment, addComment, addLabel, addLabel, annotate, annotate, annotationValues, getComment, getComment, getLabel, getLabel, hasType, 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, 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
-Node
to test, notnull
- Returns:
- the same node
- Throws:
OntJenaException
- in casenull
or 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
-Resource
to test, notnull
- Returns:
- the same resource
- Throws:
OntJenaException
- in casenull
or anonymous resource is given
-
subjects
-
findActualClass
Finds a publicOntology Object
class-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 ifview
is suitable for the given node.- Type Parameters:
X
- any subtype ofRDFNode
- Parameters:
node
-RDFNode
, notnull
view
- aClass
-type of the desired RDF view (interface)- Returns:
- an instance of the type
X
ornull
- See Also:
-
wrapAsOntObject
public static OntObject wrapAsOntObject(org.apache.jena.graph.Node node, org.apache.jena.enhanced.EnhGraph model) Creates a freshOntObject
instance.- Parameters:
node
-Node
, notnull
model
-EnhGraph
, notnull
- Returns:
OntObject
-
isReservedOrBuiltin
Returnstrue
if the given object is from reserved vocabulary (e.g.rdf:rest
is reserved in system settings).- Parameters:
object
-OntObject
- Returns:
- boolean
-
isLocal
public boolean isLocal()- Returns:
true
if the root statement belongs to the base graph
-
getMainStatement
Returns the mainOntStatement
which determines the nature of this ontological resource. In most cases it is a declaration and wraps a triple with predicaterdf:type
.The returned
OntStatement
differs 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:
getMainStatement
in 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:
spec
in interfaceOntObject
- Returns:
- Stream of
OntStatement
s - See Also:
-
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
.Impl remarks: - the method body is optimized to minimize graph querying; - we use
RDFNode
(notResource
) as generic supertype due to the fact that anOntObject
can 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:
ExtendedIterator
ofOntStatement
s
-
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:
content
in interfaceOntObject
- Returns:
- distinct Stream of
OntStatement
s - See Also:
-
findRootStatement
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.- Returns:
- Optional around
OntStatement
that 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:
statement
in 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 givenproperty
andvalue
.- Specified by:
statement
in 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:
getRequiredProperty
in interfaceOntObject
- Specified by:
getRequiredProperty
in interfaceorg.apache.jena.rdf.model.Resource
- Overrides:
getRequiredProperty
in 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:OntObject
Adds an ont-statement by attaching predicate and object (value) to this resource.- Specified by:
addStatement
in interfaceOntObject
- Parameters:
property
-Property
predicate, notnull
value
-RDFNode
object, 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:OntObject
Deletes the specific property-value pair from this object. All the corresponding statement's annotations are also deleted. In case the givenobject
isnull
, all statements with theproperty
-predicate will be deleted. No-op if no match found. -
statements
Description copied from interface:OntObject
Lists ont-statements by the predicate.- Specified by:
statements
in interfaceOntObject
- Parameters:
property
-Property
, predicate, can benull
- Returns:
Stream
ofOntStatement
s
-
statements
Description copied from interface:OntObject
Lists all top-level statements related to this object (i.e., with subject=this
).- Specified by:
statements
in interfaceOntObject
- Returns:
Stream
of all statements- See Also:
-
Resource.listProperties()
-
listProperties
public org.apache.jena.rdf.model.StmtIterator listProperties()- Specified by:
listProperties
in interfaceorg.apache.jena.rdf.model.Resource
- Overrides:
listProperties
in classorg.apache.jena.rdf.model.impl.ResourceImpl
- Returns:
StmtIterator
which containsOntStatement
s- See Also:
-
listStatements
Returns anExtended Iterator
over 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:
ExtendedIterator
over all theOntStatement
s about this object- See Also:
-
listProperties
public org.apache.jena.rdf.model.StmtIterator listProperties(org.apache.jena.rdf.model.Property p) - Specified by:
listProperties
in interfaceorg.apache.jena.rdf.model.Resource
- Overrides:
listProperties
in 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 Iterator
over 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:
ExtendedIterator
over theOntStatement
s- 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:
annotations
in interfaceOntObject
- Returns:
- Stream of
OntStatement
s - See Also:
-
listAnnotations
Lists all related annotation assertions.- Returns:
ExtendedIterator
ofOntStatement
s- See Also:
-
assertions
Lists all annotation property assertions (so-called plain annotations) attached to this object.- Returns:
- Stream of
OntStatement
s - See Also:
-
listAssertions
Returns an iterator over object's annotation property assertions. The annotation assertion is a statements with anannotation property
as predicate.- Returns:
ExtendedIterator
ofOntStatement
s- 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:
ExtendedIterator
ofLiteral
s- See Also:
-
annotationValues
Description copied from interface:OntObject
Lists 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-GB
will list also if the input language tag isen
. An empty string as language tag means searching for plain no-language literals.- Specified by:
annotationValues
in interfaceOntObject
- Parameters:
p
-OntAnnotationProperty
, notnull
lang
- String, the language tag to restrict the listed literals to, ornull
to select all literals- Returns:
Stream
of 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:
addAnnotation
in interfaceOntObject
- Parameters:
property
-OntAnnotationProperty
, Named annotation property.value
-RDFNode
the 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:subClassOf
statement, 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:
clearAnnotations
in 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
-RDFNode
type- Parameters:
predicate
-Property
view
- 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:type
attached 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
-Property
type
- 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 benull
type
- class-type of interface to find and cast, notnull
- Returns:
ExtendedIterator
ofnode
s 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 benull
type
- class-type of interface to find and cast, notnull
- Returns:
ExtendedIterator
ofnode
s 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:
ExtendedIterator
ofRDFNode
s- See Also:
-
getModel
- Specified by:
getModel
in interfaceorg.apache.jena.rdf.model.RDFNode
- Overrides:
getModel
in classorg.apache.jena.rdf.model.impl.ResourceImpl
-
objectType
Gets a public ont-object type identifier.- Specified by:
objectType
in interfaceOntObject
- Returns:
- Class, the actual type of this object
-
toString
- Specified by:
toString
in interfaceorg.apache.jena.rdf.model.RDFNode
- Specified by:
toString
in interfaceorg.apache.jena.rdf.model.Resource
- Overrides:
toString
in classorg.apache.jena.rdf.model.impl.ResourceImpl
-