- All Superinterfaces:
org.apache.jena.graph.FrontsNode,org.apache.jena.rdf.model.RDFNode,org.apache.jena.rdf.model.Resource
- All Known Subinterfaces:
OntAnnotation,OntAnnotationProperty,OntClass,OntClass.CardinalityRestriction<O,,P> OntClass.CollectionOf<O>,OntClass.ComplementOf,OntClass.ComponentRestriction<O,,P> 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,,P> OntClass.ObjectAllValuesFrom,OntClass.ObjectCardinality,OntClass.ObjectHasValue,OntClass.ObjectMaxCardinality,OntClass.ObjectMinCardinality,OntClass.ObjectSomeValuesFrom,OntClass.OneOf,OntClass.Restriction,OntClass.UnaryRestriction<P>,OntClass.UnionOf,OntClass.ValueRestriction<O,,P> OntDataProperty,OntDataRange,OntDataRange.Combination<N>,OntDataRange.ComplementOf,OntDataRange.IntersectionOf,OntDataRange.Named,OntDataRange.OneOf,OntDataRange.Restriction,OntDataRange.UnionOf,OntDisjoint<O>,OntDisjoint.Classes,OntDisjoint.DataProperties,OntDisjoint.Individuals,OntDisjoint.ObjectProperties,OntDisjoint.Properties<P>,OntEntity,OntFacetRestriction,OntFacetRestriction.FractionDigits,OntFacetRestriction.LangRange,OntFacetRestriction.Length,OntFacetRestriction.MaxExclusive,OntFacetRestriction.MaxInclusive,OntFacetRestriction.MaxLength,OntFacetRestriction.MinExclusive,OntFacetRestriction.MinInclusive,OntFacetRestriction.MinLength,OntFacetRestriction.Pattern,OntFacetRestriction.TotalDigits,OntID,OntIndividual,OntIndividual.Anonymous,OntIndividual.Named,OntNamedProperty<P>,OntNegativeAssertion<P,,V> OntNegativeAssertion.WithDataProperty,OntNegativeAssertion.WithObjectProperty,OntObjectProperty,OntObjectProperty.Inverse,OntObjectProperty.Named,OntProperty,OntRelationalProperty,OntSWRL,OntSWRL.Arg,OntSWRL.Atom<P>,OntSWRL.Atom.Binary<P,,F, S> OntSWRL.Atom.Unary<P,,A> OntSWRL.Atom.WithBuiltin,OntSWRL.Atom.WithClass,OntSWRL.Atom.WithDataProperty,OntSWRL.Atom.WithDataRange,OntSWRL.Atom.WithDifferentIndividuals,OntSWRL.Atom.WithObjectProperty,OntSWRL.Atom.WithSameIndividuals,OntSWRL.Builtin,OntSWRL.DArg,OntSWRL.IArg,OntSWRL.Imp,OntSWRL.Variable
- All Known Implementing Classes:
OntAnnotationImpl,OntAnnotationPropertyImpl,OntClassImpl,OntClassImpl.CardinalityRestrictionImpl,OntClassImpl.ComplementOfImpl,OntClassImpl.ComponentRestrictionImpl,OntClassImpl.DataAllValuesFromImpl,OntClassImpl.DataCardinalityImpl,OntClassImpl.DataHasValueImpl,OntClassImpl.DataMaxCardinalityImpl,OntClassImpl.DataMinCardinalityImpl,OntClassImpl.DataSomeValuesFromImpl,OntClassImpl.HasSelfImpl,OntClassImpl.IntersectionOfImpl,OntClassImpl.NaryDataAllValuesFromImpl,OntClassImpl.NaryDataSomeValuesFromImpl,OntClassImpl.NaryRestrictionImpl,OntClassImpl.ObjectAllValuesFromImpl,OntClassImpl.ObjectCardinalityImpl,OntClassImpl.ObjectHasValueImpl,OntClassImpl.ObjectMaxCardinalityImpl,OntClassImpl.ObjectMinCardinalityImpl,OntClassImpl.ObjectSomeValuesFromImpl,OntClassImpl.OneOfImpl,OntClassImpl.OnPropertyRestrictionImpl,OntClassImpl.QLComplementOfImpl,OntClassImpl.QLDataSomeValuesFromImpl,OntClassImpl.QLIntersectionOfImpl,OntClassImpl.QLObjectSomeValuesFromImpl,OntClassImpl.RestrictionImpl,OntClassImpl.RLComplementOfImpl,OntClassImpl.RLDataAllValuesFromImpl,OntClassImpl.RLDataMaxCardinalityImpl,OntClassImpl.RLDataSomeValuesFromImpl,OntClassImpl.RLIntersectionOfImpl,OntClassImpl.RLObjectAllValuesFromImpl,OntClassImpl.RLObjectMaxCardinalityImpl,OntClassImpl.RLObjectSomeValuesFromImpl,OntClassImpl.RLOneOfImpl,OntClassImpl.RLUnionOfImpl,OntClassImpl.UnionOfImpl,OntDataPropertyImpl,OntDataRangeImpl,OntDataRangeImpl.ComplementOfImpl,OntDataRangeImpl.IntersectionOfImpl,OntDataRangeImpl.OneOfImpl,OntDataRangeImpl.RestrictionImpl,OntDataRangeImpl.UnionOfImpl,OntDisjointImpl,OntDisjointImpl.ClassesImpl,OntDisjointImpl.DataPropertiesImpl,OntDisjointImpl.IndividualsImpl,OntDisjointImpl.ObjectPropertiesImpl,OntDisjointImpl.PropertiesImpl,OntDisjointImpl.QLRLClassesImpl,OntFacetRestrictionImpl,OntFacetRestrictionImpl.FractionDigitsImpl,OntFacetRestrictionImpl.LangRangeImpl,OntFacetRestrictionImpl.LengthImpl,OntFacetRestrictionImpl.MaxExclusiveImpl,OntFacetRestrictionImpl.MaxInclusiveImpl,OntFacetRestrictionImpl.MaxLengthImpl,OntFacetRestrictionImpl.MinExclusiveImpl,OntFacetRestrictionImpl.MinInclusiveImpl,OntFacetRestrictionImpl.MinLengthImpl,OntFacetRestrictionImpl.PatternImpl,OntFacetRestrictionImpl.TotalDigitsImpl,OntIDImpl,OntIndividualImpl,OntIndividualImpl.AnonymousImpl,OntIndividualImpl.NamedImpl,OntNamedDataRangeImpl,OntNegativePropertyAssertionImpl,OntNegativePropertyAssertionImpl.DataAssertionImpl,OntNegativePropertyAssertionImpl.ObjectAssertionImpl,OntObjectImpl,OntObjectPropertyImpl,OntObjectPropertyImpl.InversePropertyImpl,OntObjectPropertyImpl.NamedImpl,OntPropertyImpl,OntSimpleClassImpl,OntSimpleClassImpl.NamedImpl,OntSimpleClassImpl.RLNamedImpl,OntSimplePropertyImpl,OntSWRLImpl,OntSWRLImpl.AtomImpl,OntSWRLImpl.BinaryImpl,OntSWRLImpl.BuiltInAtomImpl,OntSWRLImpl.BuiltinImpl,OntSWRLImpl.DArgImpl,OntSWRLImpl.DataPropertyAtomImpl,OntSWRLImpl.DataRangeAtomImpl,OntSWRLImpl.DifferentIndividualsAtomImpl,OntSWRLImpl.IArgImpl,OntSWRLImpl.ImpImpl,OntSWRLImpl.IndividualsAtomImpl,OntSWRLImpl.ObjectPropertyAtomImpl,OntSWRLImpl.OntClassAtomImpl,OntSWRLImpl.PropertyAtomImpl,OntSWRLImpl.SameIndividualsAtomImpl,OntSWRLImpl.UnaryImpl,OntSWRLImpl.VariableImpl
Ontology Object RDF Resource.
A common super-type for all the abstractions in the Ontology RDF Model,
which support Jena Polymorphism,
can be annotated and have a structure strictly defined according to the OWL2 specification.-
Method Summary
Modifier and TypeMethodDescriptiondefault OntStatementaddAnnotation(OntAnnotationProperty predicate, String lexicalForm) Adds no-lang annotation assertion.default OntStatementaddAnnotation(OntAnnotationProperty predicate, String txt, String lang) Adds lang annotation assertion.addAnnotation(OntAnnotationProperty property, org.apache.jena.rdf.model.RDFNode value) Adds an annotation assertion with the givenannotation propertyas predicate andRDF Nodeas value.default OntObjectaddComment(String txt) Creates_:this rdfs:comment "txt"^^xsd:stringstatement.default OntObjectaddComment(String txt, String lang) Adds the given localized text annotation with builtinrdfs:commentpredicate.default OntObjectCreates_:this rdfs:label "txt"^^xsd:stringstatement.default OntObjectAdds the given localized text annotation with builtinrdfs:labelpredicate.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.default OntObjectannotate(OntAnnotationProperty predicate, String txt, String lang) Adds a language-tagged text for this object and the givenpredicatedefault OntObjectannotate(OntAnnotationProperty predicate, org.apache.jena.rdf.model.RDFNode value) Annotates the object with the givenpredicateandvalue.Lists all top-level annotations attached to the root statement of this object.default Stream<org.apache.jena.rdf.model.RDFNode>annotationValues(OntAnnotationProperty predicate) Lists all annotation values for the given predicate.annotationValues(OntAnnotationProperty predicate, String lang) Lists all annotation literals for the given predicate and the language tag.Removes all root annotations including their sub-annotations hierarchy.content()Lists the content of the object, i.e., all characteristic statements (seespec()), 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).default <X extends org.apache.jena.rdf.model.RDFNode>
XSafely converts this RDF resource to the giventypeinterface, if it is possible.default StringAnswers the comment string for this object.default StringgetComment(String lang) Answers the comment string for this object.default StringgetLabel()Answers the label string for this object.default StringAnswers the label string for this object.Returns the mainOntStatementwhich determines the nature of this ontological resource.getModel()Returns the ontology model associated with this resource.getRequiredProperty(org.apache.jena.rdf.model.Property property) Returns the first statement for the specified property.default booleanhasType(org.apache.jena.rdf.model.Resource type) Answerstrueiff this object has the declaration triplethis rdf:type type, wheretypeis what specified as parameter.booleanisLocal()Determines if this Ontology Resource is locally defined.Stream<org.apache.jena.rdf.model.RDFNode>objects(org.apache.jena.rdf.model.Property predicate) Lists all objects attached on the property to this object.<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 object) 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.default Stream<org.apache.jena.rdf.model.Resource>types()Lists all declarations (statements withrdf:typepredicate).Methods inherited from interface org.apache.jena.graph.FrontsNode
asNodeMethods 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
-
Method Details
-
objectType
Gets a public ont-object type identifier.- Returns:
- Class, the actual type of this object
-
getMainStatement
OntStatement 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.- Returns:
OntStatementornullin some boundary cases (e.g., for builtins)- See Also:
-
spec
Stream<OntStatement> 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.
getMainStatement()), or even will be empty for built-in entities and individuals.- Returns:
StreamofOntology Statements- See Also:
-
content
Stream<OntStatement> content()Lists the content of the object, i.e., all characteristic statements (seespec()), 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).- Returns:
StreamofOntology Statements- See Also:
-
addStatement
OntStatement 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.- Parameters:
property-Propertypredicate, notnullvalue-RDFNodeobject, notnull- Returns:
OntStatement- See Also:
-
Resource.addProperty(Property, RDFNode)
-
remove
OntObject remove(org.apache.jena.rdf.model.Property property, org.apache.jena.rdf.model.RDFNode object) Deletes 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.- Parameters:
property-Propertypredicate, notnullobject-RDFNodeobject, can benull- Returns:
- this object to allow cascading calls
- See Also:
-
statements
Lists ont-statements by the predicate.- Parameters:
property-Property, predicate, can benull- Returns:
StreamofOntStatements
-
statements
Stream<OntStatement> statements()Lists all top-level statements related to this object (i.e., with subject=this).- Returns:
Streamof all statements- See Also:
-
Resource.listProperties()
-
statement
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.- Parameters:
property-Property, the predicatevalue-RDFNode, the object- Returns:
OptionalaroundOntStatement
-
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.- Parameters:
property-Property, can benull- Returns:
OptionalaroundOntStatement- See Also:
-
Resource.getProperty(Property)
-
objects
<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.- Type Parameters:
O- a class-type of rdf-node- Parameters:
predicate-Propertypredicate, can benullfor wildcard searchingtype- Interface to find and cast- Returns:
StreamofRDF Nodes of the typeO
-
objects
Lists all objects attached on the property to this object.- Parameters:
predicate-Propertypredicate, can benullfor wildcard searching- Returns:
StreamofRDF Nodes
-
addAnnotation
Adds an annotation assertion with the givenannotation propertyas predicate andRDF Nodeas value. The method is equivalent to the expressiongetRoot().addAnnotation(property, value).- Parameters:
property-OntAnnotationProperty- named annotation propertyvalue-RDFNode- the value: uri-resource, literal or anonymous individual- Returns:
OntStatementfor newly added annotation to provide the possibility of adding subsequent sub-annotations- Throws:
OntJenaException- in case input is wrong- See Also:
-
annotations
Stream<OntStatement> annotations()Lists all top-level annotations attached to the root statement of this object. Each annotation can be plain (annotation property assertion) or bulk (anonymous resource with the typeowl:Axiomorowl:Annotation, possibly with sub-annotations). Sub-annotations are not included in the returned stream. For non-built-in ontology objects this is equivalent to the expressiongetRoot().annotations().- Returns:
StreamofOntStatements that have anannotation propertyas predicate- See Also:
-
annotationValues
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-GBwill list also if the input language tag isen. An empty string as language tag means searching for plain no-language literals.- Parameters:
predicate-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:
-
clearAnnotations
OntObject 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().- Returns:
- this object to allow cascading calls
- See Also:
-
getRequiredProperty
Returns the first statement for the specified property. What exactly is the first triple is defined at the level of graph and, in general, it is unpredictable.- Specified by:
getRequiredPropertyin interfaceorg.apache.jena.rdf.model.Resource- Parameters:
property-Property, the predicate- Returns:
OntStatement- Throws:
org.apache.jena.shared.PropertyNotFoundException- if no such statement found- See Also:
-
Resource.getRequiredProperty(Property)
-
hasType
default boolean hasType(org.apache.jena.rdf.model.Resource type) Answerstrueiff this object has the declaration triplethis rdf:type type, wheretypeis what specified as parameter.- Parameters:
type-Resourceto test- Returns:
trueif the given type is present
-
types
Lists all declarations (statements withrdf:typepredicate).- Returns:
StreamofResources
-
annotationValues
Lists all annotation values for the given predicate.- Parameters:
predicate-OntAnnotationProperty, notnull- Returns:
StreamofRDFNodes- See Also:
-
addAnnotation
Adds no-lang annotation assertion.- Parameters:
predicate-OntAnnotationPropertypredicatelexicalForm- String, the literal lexical form, notnull- Returns:
OntStatement
-
addAnnotation
Adds lang annotation assertion.- Parameters:
predicate-OntAnnotationPropertypredicatetxt- String, the literal lexical form, notnulllang- String, the language tag, nullable- Returns:
OntStatement- new statement:@subject @predicate "txt"@lang
-
annotate
default OntObject annotate(OntAnnotationProperty predicate, org.apache.jena.rdf.model.RDFNode value) Annotates the object with the givenpredicateandvalue.- Parameters:
predicate-OntAnnotationProperty- named annotation property, notnullvalue-RDFNode- the value: uri-resource, literal or anonymous individual, notnull- Returns:
- this object to allow cascading calls
- See Also:
-
annotate
Adds a language-tagged text for this object and the givenpredicate- Parameters:
predicate-OntAnnotationProperty- named annotation property, notnulltxt- String, the literal lexical form, cannot benulllang- String, the language tag, can benull- Returns:
- this object to allow cascading calls
-
addComment
Creates_:this rdfs:comment "txt"^^xsd:stringstatement.- Parameters:
txt- String, notnull- Returns:
- this object to allow cascading calls
- See Also:
-
addComment
Adds the given localized text annotation with builtinrdfs:commentpredicate.- Parameters:
txt- String, the literal lexical form, notnulllang- String, the language tag, nullable- Returns:
- this object to allow cascading calls
- See Also:
-
addLabel
Creates_:this rdfs:label "txt"^^xsd:stringstatement.- Parameters:
txt- String, the literal lexical form, notnull- Returns:
- this object to allow cascading calls
- See Also:
-
addLabel
Adds the given localized text annotation with builtinrdfs:labelpredicate.- Parameters:
txt- String, the literal lexical form, notnulllang- String, the language tag, nullable- Returns:
- this object to allow cascading calls
- See Also:
-
getComment
Answers the comment string for this object. If there is more than one such resource, an arbitrary selection is made.- Returns:
- a
rdfs:commentstring ornullif there is no comments - See Also:
-
getComment
Answers the comment string for this object. If there is more than one such resource, an arbitrary selection is made.- Parameters:
lang- String, the language attribute for the desired comment (EN, FR, etc.) ornullfor don't care; will attempt to retrieve the most specific comment matching the given language; to get no-lang literal string an empty string can be used- Returns:
- a
rdfs:commentstring matching the given language, ornullif there is no matching comment - See Also:
-
getLabel
Answers the label string for this object. If there is more than one such resource, an arbitrary selection is made.- Returns:
- a
rdfs:labelstring ornullif there is no comments - See Also:
-
getLabel
Answers the label string for this object. If there is more than one such resource, an arbitrary selection is made.- Parameters:
lang- String, the language attribute for the desired comment (EN, FR, etc.) ornullfor don't care; will attempt to retrieve the most specific comment matching the given language; to get no-lang literal string an empty string can be used- Returns:
- a
rdfs:labelstring matching the given language, ornullif there is no matching label - 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)
-