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 propertyandRDF Nodevalue 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.booleanAnswerstrueiff this statement is a part ofBulk Annotation Ontology Object.booleanbooleanRemoves all sub-annotations including their children.static OntStatementImplcreateNotAnnotatedOntStatementImpl(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.RDFNodecreateObject(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 OntStatementImplcreateOntStatementImpl(org.apache.jena.graph.Triple t, OntGraphModelImpl m) Creates an OntStatement impl from the given Triple.static OntStatementImplcreateOntStatementImpl(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 OntStatementImplcreateOntStatementImpl(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 OntStatementImplcreateOntStatementImpl(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 theListof annotations sorted by some internal order.getModel()Gets theOntology RDF ModelthisStatementwas 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.NodebooleanhasAnnotatedProperty(org.apache.jena.rdf.model.Property property) booleanhasAnnotatedTarget(org.apache.jena.rdf.model.RDFNode object) booleanAnswerstrueiff this statement has any annotations attached (either plain or bulk).booleanbooleanisLocal()Answerstrueiff this statement is in the base graph.booleanAnswerstrueiff 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, toStatementMethods 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, toStringMethods inherited from interface org.apache.jena.graph.FrontsTriple
asTripleMethods inherited from interface org.apache.jena.ontapi.model.OntStatement
addAnnotation, addAnnotation, annotate, annotate, annotate, annotations, asAnnotationResource, deleteAnnotation, getObject, isAnnotationAssertion, isDeclarationMethods 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-Triplenot nullm-OntGraphModelImplmodel- Returns:
OntStatementImplfresh 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-Resourcesubjectp-Graph RDF URI Nodepredicateo-Graph RDF Nodeobjectm-OntGraphModelImplmodel- Returns:
OntStatementImplfresh 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-Resourcesubjectp-Propertypredicateo-Graph RDF Nodeobjectm-OntGraphModelImplmodel- Returns:
OntStatementImplfresh 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-Resourcesubjectp-Propertypredicateo-Model RDF Nodeobjectm-OntGraphModelImplmodel- Returns:
OntStatementImplfresh 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, notnullg-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-Resourcesubjectp-Propertypredicateo-RDFNodeobjectm-OntGraphModelImplmodel- 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, notnulls-OntStatementImpl, notnull- Returns:
ExtendedIteratorof annotationresources
-
getModel
Description copied from interface:OntStatementGets theOntology RDF ModelthisStatementwas created in.- Specified by:
getModelin interfaceOntStatement- Specified by:
getModelin interfaceorg.apache.jena.rdf.model.Statement- Overrides:
getModelin classorg.apache.jena.rdf.model.impl.StatementBase- Returns:
OntModel
-
isRootStatement
public boolean isRootStatement()Answerstrueiff 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 objects.- Returns:
trueif it is a main object statement- See Also:
-
asRootStatement
-
isLocal
public boolean isLocal()Description copied from interface:OntStatementAnswerstrueiff this statement is in the base graph. The method is equivalent to the expressionthis.getModel().getBaseGraph().contains(this.asTriple()).- Specified by:
isLocalin interfaceOntStatement- Returns:
trueif it is a local statement- See Also:
-
OntResource.isLocal()
-
isAnnotationRootStatement
public boolean isAnnotationRootStatement() -
getSubject
Description copied from interface:OntStatementAn accessor method to return the subject of the statements in form ofOntology Object.- Specified by:
getSubjectin interfaceOntStatement- Specified by:
getSubjectin interfaceorg.apache.jena.rdf.model.Statement- Overrides:
getSubjectin 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:OntStatementAnswers a typed subject of the statement.- Specified by:
getSubjectin interfaceOntStatement- Type Parameters:
N- subtype ofResource- Parameters:
type- Class type- Returns:
Resourceinstance- See Also:
-
belongsToAnnotation
public boolean belongsToAnnotation()Answerstrueiff 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 cachesOntAnnotationin the model.- Specified by:
belongsToAnnotationin interfaceOntStatement- Returns:
- boolean
- See Also:
-
addAnnotation
public OntStatement addAnnotation(OntAnnotationProperty property, org.apache.jena.rdf.model.RDFNode value) Description copied from interface:OntStatementAnnotates the statement with the givenannotation propertyandRDF Nodevalue 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 returnedOntStatementhas 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 resourceand its subject is a blank node.- Specified by:
addAnnotationin interfaceOntStatement- Parameters:
property-OntAnnotationPropertynamed annotation property, notnullvalue-RDFNodeuri-resource, literal or anonymous individual, notnull- Returns:
- a new
Ont-Statementfor newly added annotation - See Also:
-
annotations
Description copied from interface:OntStatementLists 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:
annotationsin interfaceOntStatement- Returns:
- Stream (unordered) of
annotation assertion statements withannotation propertyas predicates, can be empty - See Also:
-
hasAnnotations
public boolean hasAnnotations()Description copied from interface:OntStatementAnswerstrueiff this statement has any annotations attached (either plain or bulk).- Specified by:
hasAnnotationsin interfaceOntStatement- Returns:
trueif it is annotated
-
listAnnotations
Lists all annotation assertion statements related to this one.- Returns:
ExtendedIteratorofOntStatements- See Also:
-
clearAnnotations
Description copied from interface:OntStatementRemoves all sub-annotations including their children.- Specified by:
clearAnnotationsin 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:OntStatementDeletes 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 correspondingOntAnnotationresource has no assertions anymore, it deletes the whole OntAnnotation resource also.- Specified by:
deleteAnnotationin interfaceOntStatement- Parameters:
property-OntAnnotationPropertynamed annotation property, notnullvalue-RDFNodeuri-resource, literal or anonymous individual, notnull- Returns:
- this statement instance to allow cascading calls
- See Also:
-
annotationResources
Description copied from interface:OntStatementReturns the stream of the annotation objects attached to this statement. E.g., for the statements A tthe 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:
annotationResourcesin interfaceOntStatement- Returns:
- Stream (unordered) of
OntAnnotationresources - See Also:
-
getAnnotationList
Returns theListof annotations sorted by some internal order.- Specified by:
getAnnotationListin interfaceOntStatement- Returns:
- List of
OntAnnotations - See Also:
-
listAnnotationResources
Returns the iterator of annotation objects attached to this statement.- Returns:
ExtendedIteratorofOntAnnotations- 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:
ExtendedIteratorofOntStatements
-