java.lang.Object
org.apache.jena.rdf.model.impl.StatementBase
org.apache.jena.rdf.model.impl.StatementImpl
org.apache.jena.ontapi.impl.objects.OntStatementImpl
- All Implemented Interfaces:
org.apache.jena.graph.FrontsTriple
,OntStatement
,org.apache.jena.rdf.model.Statement
public class OntStatementImpl
extends org.apache.jena.rdf.model.impl.StatementImpl
implements OntStatement
An implementation of
Ontology Statement
.
This is an extended Jena StatementImpl
with possibility to add, delete and find annotations
in the same form of OntStatement
.
Annotations can be plain (annotation assertion) or bulk (anonymous resource with
rdf:type
owl:Axiom
or owl:Annotation
,
for more details see OntAnnotation
).
The examples of how to write bulk-annotations in RDF-graph see here:
2.2 Translation of Annotations.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOntStatementImpl
(org.apache.jena.rdf.model.Resource subject, org.apache.jena.rdf.model.Property predicate, org.apache.jena.rdf.model.RDFNode object, OntModel model) OntStatementImpl
(org.apache.jena.rdf.model.Statement statement) -
Method Summary
Modifier and TypeMethodDescriptionaddAnnotation
(OntAnnotationProperty property, org.apache.jena.rdf.model.RDFNode value) Annotates the statement with the givenannotation property
andRDF Node
value and returns a newly added annotation assertion statement.Returns the stream of the annotation objects attached to this statement.Lists all annotations related to this statement.boolean
Answerstrue
iff this statement is a part ofBulk Annotation Ontology Object
.boolean
boolean
Removes all sub-annotations including their children.static OntStatementImpl
createNotAnnotatedOntStatementImpl
(org.apache.jena.rdf.model.Resource s, org.apache.jena.rdf.model.Property p, org.apache.jena.rdf.model.RDFNode o, OntGraphModelImpl m) Creates an ont-statement that does not support sub-annotations.static org.apache.jena.rdf.model.RDFNode
createObject
(org.apache.jena.graph.Node n, org.apache.jena.enhanced.EnhGraph g) Creates an RDF node which might be a literal or resource, in the latter case it is wrapped asOntObjectImpl
.static OntStatementImpl
createOntStatementImpl
(org.apache.jena.graph.Triple t, OntGraphModelImpl m) Creates an OntStatement impl from the given Triple.static OntStatementImpl
createOntStatementImpl
(org.apache.jena.rdf.model.Resource s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o, OntGraphModelImpl m) Creates an OntStatement impl with the given SPO.static OntStatementImpl
createOntStatementImpl
(org.apache.jena.rdf.model.Resource s, org.apache.jena.rdf.model.Property p, org.apache.jena.graph.Node o, OntGraphModelImpl m) Creates an OntStatement-impl with the given SPO.static OntStatementImpl
createOntStatementImpl
(org.apache.jena.rdf.model.Resource s, org.apache.jena.rdf.model.Property p, org.apache.jena.rdf.model.RDFNode o, OntGraphModelImpl m) Creates an OntStatement impl with the given SPO.deleteAnnotation
(OntAnnotationProperty property, org.apache.jena.rdf.model.RDFNode value) Deletes the child annotation if present.Returns theList
of annotations sorted by some internal order.getModel()
Gets theOntology RDF Model
thisStatement
was created in.An accessor method to return the subject of the statements in form ofOntology Object
.<N extends org.apache.jena.rdf.model.Resource>
NgetSubject
(Class<N> type) Answers a typed subject of the statement.org.apache.jena.graph.Node
boolean
hasAnnotatedProperty
(org.apache.jena.rdf.model.Property property) boolean
hasAnnotatedTarget
(org.apache.jena.rdf.model.RDFNode object) boolean
Answerstrue
iff this statement has any annotations attached (either plain or bulk).boolean
boolean
isLocal()
Answerstrue
iff this statement is in the base graph.boolean
Answerstrue
iff this statement is a main (i.e. it is a definition of someOntObject
).org.apache.jena.util.iterator.ExtendedIterator<OntAnnotation>
Returns the iterator of annotation objects attached to this statement.static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.rdf.model.Resource>
Lists all (bulk) annotation anonymous resources form the specified model and for the given statement (SPO).org.apache.jena.util.iterator.ExtendedIterator<OntStatement>
Lists all annotation assertion statements related to this one.org.apache.jena.util.iterator.ExtendedIterator<OntStatement>
Splits the statement into several equivalent ones but with disjoint annotations.Methods inherited from class org.apache.jena.rdf.model.impl.StatementImpl
asTriple, asTriples, equals, getAlt, getBag, getList, getLiteral, getObject, getPredicate, getProperty, getResource, getSeq, getStatementProperty, hashCode, remove, toStatement
Methods inherited from class org.apache.jena.rdf.model.impl.StatementBase
changeLiteralObject, changeLiteralObject, changeLiteralObject, changeLiteralObject, changeLiteralObject, changeLiteralObject, changeObject, changeObject, changeObject, getBoolean, getByte, getChar, getDouble, getFloat, getInt, getLanguage, getLong, getShort, getString, toString
Methods inherited from interface org.apache.jena.graph.FrontsTriple
asTriple
Methods inherited from interface org.apache.jena.ontapi.model.OntStatement
addAnnotation, addAnnotation, annotate, annotate, annotate, annotations, asAnnotationResource, deleteAnnotation, getObject, isAnnotationAssertion, isDeclaration
Methods inherited from interface org.apache.jena.rdf.model.Statement
changeLiteralObject, changeLiteralObject, changeLiteralObject, changeLiteralObject, changeLiteralObject, changeLiteralObject, changeObject, changeObject, changeObject, equals, getAlt, getBag, getBoolean, getByte, getChar, getDouble, getFloat, getInt, getLanguage, getList, getLiteral, getLong, getObject, getPredicate, getProperty, getResource, getSeq, getShort, getStatementProperty, getString, hashCode, remove
-
Constructor Details
-
OntStatementImpl
public OntStatementImpl(org.apache.jena.rdf.model.Statement statement) throws ClassCastException, NullPointerException -
OntStatementImpl
public OntStatementImpl(org.apache.jena.rdf.model.Resource subject, org.apache.jena.rdf.model.Property predicate, org.apache.jena.rdf.model.RDFNode object, OntModel model)
-
-
Method Details
-
createOntStatementImpl
public static OntStatementImpl createOntStatementImpl(org.apache.jena.graph.Triple t, OntGraphModelImpl m) Creates an OntStatement impl from the given Triple. The OntStatement has subject, predicate, and object corresponding to those of Triple.- Parameters:
t
-Triple
not nullm
-OntGraphModelImpl
model- Returns:
OntStatementImpl
fresh instance
-
createOntStatementImpl
public static OntStatementImpl createOntStatementImpl(org.apache.jena.rdf.model.Resource s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o, OntGraphModelImpl m) Creates an OntStatement impl with the given SPO.- Parameters:
s
-Resource
subjectp
-Graph RDF URI Node
predicateo
-Graph RDF Node
objectm
-OntGraphModelImpl
model- Returns:
OntStatementImpl
fresh instance
-
createOntStatementImpl
public static OntStatementImpl createOntStatementImpl(org.apache.jena.rdf.model.Resource s, org.apache.jena.rdf.model.Property p, org.apache.jena.graph.Node o, OntGraphModelImpl m) Creates an OntStatement-impl with the given SPO.- Parameters:
s
-Resource
subjectp
-Property
predicateo
-Graph RDF Node
objectm
-OntGraphModelImpl
model- Returns:
OntStatementImpl
fresh instance
-
createOntStatementImpl
public static OntStatementImpl createOntStatementImpl(org.apache.jena.rdf.model.Resource s, org.apache.jena.rdf.model.Property p, org.apache.jena.rdf.model.RDFNode o, OntGraphModelImpl m) Creates an OntStatement impl with the given SPO.- Parameters:
s
-Resource
subjectp
-Property
predicateo
-Model RDF Node
objectm
-OntGraphModelImpl
model- Returns:
OntStatementImpl
fresh instance
-
createObject
public static org.apache.jena.rdf.model.RDFNode createObject(org.apache.jena.graph.Node n, org.apache.jena.enhanced.EnhGraph g) Creates an RDF node which might be a literal or resource, in the latter case it is wrapped asOntObjectImpl
. The result is used in a statement at object position.- Parameters:
n
-Node
, notnull
g
-EnhGraph
, notnull
- Returns:
RDFNode
- See Also:
-
StatementImpl.createObject(Node, EnhGraph)
-
createNotAnnotatedOntStatementImpl
public static OntStatementImpl createNotAnnotatedOntStatementImpl(org.apache.jena.rdf.model.Resource s, org.apache.jena.rdf.model.Property p, org.apache.jena.rdf.model.RDFNode o, OntGraphModelImpl m) Creates an ont-statement that does not support sub-annotations. The method does not change the model.- Parameters:
s
-Resource
subjectp
-Property
predicateo
-RDFNode
objectm
-OntGraphModelImpl
model- Returns:
OntStatementImpl
-
listAnnotationResources
public static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.rdf.model.Resource> listAnnotationResources(OntGraphModelImpl m, OntStatementImpl s) Lists all (bulk) annotation anonymous resources form the specified model and for the given statement (SPO).- Parameters:
m
-OntGraphModelImpl
, notnull
s
-OntStatementImpl
, notnull
- Returns:
ExtendedIterator
of annotationresource
s
-
getModel
Description copied from interface:OntStatement
Gets theOntology RDF Model
thisStatement
was created in.- Specified by:
getModel
in interfaceOntStatement
- Specified by:
getModel
in interfaceorg.apache.jena.rdf.model.Statement
- Overrides:
getModel
in classorg.apache.jena.rdf.model.impl.StatementBase
- Returns:
OntModel
-
isRootStatement
public boolean isRootStatement()Answerstrue
iff this statement is a main (i.e. it is a definition of someOntObject
). For any otherOntStatement
(i.e. for those obtained from the model level) the method returnsfalse
. A main statement can have annotation assertions attached, while a regular statement is always annotated withbulk annotation object
s.- Returns:
true
if it is a main object statement- See Also:
-
asRootStatement
-
isLocal
public boolean isLocal()Description copied from interface:OntStatement
Answerstrue
iff this statement is in the base graph. The method is equivalent to the expressionthis.getModel().getBaseGraph().contains(this.asTriple())
.- Specified by:
isLocal
in interfaceOntStatement
- Returns:
true
if it is a local statement- See Also:
-
OntResource.isLocal()
-
isAnnotationRootStatement
public boolean isAnnotationRootStatement() -
getSubject
Description copied from interface:OntStatement
An accessor method to return the subject of the statements in form ofOntology Object
.- Specified by:
getSubject
in interfaceOntStatement
- Specified by:
getSubject
in interfaceorg.apache.jena.rdf.model.Statement
- Overrides:
getSubject
in classorg.apache.jena.rdf.model.impl.StatementImpl
- Returns:
OntObject
- See Also:
-
Statement.getSubject()
-
getSubjectNode
public org.apache.jena.graph.Node getSubjectNode() -
getSubject
Description copied from interface:OntStatement
Answers a typed subject of the statement.- Specified by:
getSubject
in interfaceOntStatement
- Type Parameters:
N
- subtype ofResource
- Parameters:
type
- Class type- Returns:
Resource
instance- See Also:
-
belongsToAnnotation
public boolean belongsToAnnotation()Answerstrue
iff this statement is a part ofBulk Annotation Ontology Object
. This means that it is one of the following:
In case of_:x rdf:type owl:Annotation . _:x p v . _:x owl:annotatedSource this . _:x owl:annotatedProperty x . _:x owl:annotatedTarget y .
true
, this method also cachesOntAnnotation
in the model.- Specified by:
belongsToAnnotation
in interfaceOntStatement
- Returns:
- boolean
- See Also:
-
addAnnotation
public OntStatement addAnnotation(OntAnnotationProperty property, org.apache.jena.rdf.model.RDFNode value) Description copied from interface:OntStatement
Annotates the statement with the givenannotation property
andRDF Node
value and returns a newly added annotation assertion statement.In the special case of a main statement (i.e., if this statement is a result of
OntObject.getMainStatement()
) the returnedOntStatement
has the same subject as this statement, and it is called a plain annotation assertion (in this case the method is equivalent to theOntObject.addAnnotation(OntAnnotationProperty, RDFNode)
method). Otherwise, the returned statement is a part of a fresh or existingbulk annotation resource
and its subject is a blank node.- Specified by:
addAnnotation
in interfaceOntStatement
- Parameters:
property
-OntAnnotationProperty
named annotation property, notnull
value
-RDFNode
uri-resource, literal or anonymous individual, notnull
- Returns:
- a new
Ont-Statement
for newly added annotation - See Also:
-
annotations
Description copied from interface:OntStatement
Lists all annotations related to this statement. The returned stream consists of annotation assertions listed from the top-level bulk annotations plus plain annotation assertions in the special case of the main statement.- Specified by:
annotations
in interfaceOntStatement
- Returns:
- Stream (unordered) of
annotation assertion statement
s withannotation property
as predicates, can be empty - See Also:
-
hasAnnotations
public boolean hasAnnotations()Description copied from interface:OntStatement
Answerstrue
iff this statement has any annotations attached (either plain or bulk).- Specified by:
hasAnnotations
in interfaceOntStatement
- Returns:
true
if it is annotated
-
listAnnotations
Lists all annotation assertion statements related to this one.- Returns:
ExtendedIterator
ofOntStatement
s- See Also:
-
clearAnnotations
Description copied from interface:OntStatement
Removes all sub-annotations including their children.- Specified by:
clearAnnotations
in interfaceOntStatement
- Returns:
- this statement to allow cascading calls
- See Also:
-
deleteAnnotation
public OntStatementImpl deleteAnnotation(OntAnnotationProperty property, org.apache.jena.rdf.model.RDFNode value) Description copied from interface:OntStatement
Deletes the child annotation if present. Does nothing if no assertion found. Throws an exception if specified annotation has it its own annotations. If this statement is not root and the correspondingOntAnnotation
resource has no assertions anymore, it deletes the whole OntAnnotation resource also.- Specified by:
deleteAnnotation
in interfaceOntStatement
- Parameters:
property
-OntAnnotationProperty
named annotation property, notnull
value
-RDFNode
uri-resource, literal or anonymous individual, notnull
- Returns:
- this statement instance to allow cascading calls
- See Also:
-
annotationResources
Description copied from interface:OntStatement
Returns the stream of the annotation objects attached to this statement. E.g., for the statements A t
the annotation object looks like
Technically, although it usually does not make sense, it is allowed that a statement may have several such b-nodes._:b0 a owl:Axiom . _:b0 Aj tj . _:b0 owl:annotatedSource s . _:b0 owl:annotatedProperty A . _:b0 owl:annotatedTarget t .
- Specified by:
annotationResources
in interfaceOntStatement
- Returns:
- Stream (unordered) of
OntAnnotation
resources - See Also:
-
getAnnotationList
Returns theList
of annotations sorted by some internal order.- Specified by:
getAnnotationList
in interfaceOntStatement
- Returns:
- List of
OntAnnotation
s - See Also:
-
listAnnotationResources
Returns the iterator of annotation objects attached to this statement.- Returns:
ExtendedIterator
ofOntAnnotation
s- See Also:
-
belongsToOWLAnnotation
public boolean belongsToOWLAnnotation() -
belongsToOWLAxiom
public boolean belongsToOWLAxiom() -
hasAnnotatedProperty
public boolean hasAnnotatedProperty(org.apache.jena.rdf.model.Property property) -
hasAnnotatedTarget
public boolean hasAnnotatedTarget(org.apache.jena.rdf.model.RDFNode object) -
listSplitStatements
Splits the statement into several equivalent ones but with disjoint annotations. Warning: this method stores annotation-resources to memory.- Returns:
ExtendedIterator
ofOntStatement
s
-