OWL Model
and all related objects:
Ontology Object
,
Ontology Entity
,
Node List
,
Ontology Statement
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Stream<OntStatement>
annotations
(OntStatement statement) Recursively lists all annotations for the givenOntology Statement
in the form of a flat stream.static OntIndividual.Anonymous
asAnonymousIndividual
(org.apache.jena.rdf.model.RDFNode inModel) Creates an anonymous individual for the givenRDF Node
, that must be associated with a model.static OntConfig
Gets model's config.static Set<OntStatement>
getAllAnnotations
(OntStatement statement) For the specifiedStatement
gets all its annotation assertions recursively including their sub-annotations.static OntClass
Answers the lowest common ancestor of two classes.static OntClass
Answers the lowest common ancestor of two classes, assuming that the given class is the root concept to start searching from.getOntType
(O object) Determines the actual ontology object type.static org.apache.jena.util.iterator.ExtendedIterator<OntStatement>
listAllAnnotations
(OntStatement statement) For the specifiedStatement
lists all its annotation assertions recursively including their sub-annotations.static org.apache.jena.util.iterator.ExtendedIterator<OntStatement>
Lists all direct object's annotations.static org.apache.jena.util.iterator.ExtendedIterator<OntStatement>
Returns an iterator over all direct annotations of the given ontology statement.static org.apache.jena.util.iterator.ExtendedIterator<OntClass>
Lists all class-types for the given individual.static org.apache.jena.util.iterator.ExtendedIterator<OntModel>
listImports
(OntModel model) Lists all imported models from the given one.static org.apache.jena.util.iterator.ExtendedIterator<OntEntity>
listLocalEntities
(OntModel model) Lists all OWL entities that are defined in the base graph.static <O extends OntObject>
org.apache.jena.util.iterator.ExtendedIterator<O>listLocalObjects
(OntModel model, Class<? extends O> type) Lists all ontology objects with the giventype
that are defined in the base graph.static org.apache.jena.util.iterator.ExtendedIterator<OntStatement>
listLocalStatements
(OntModel model, org.apache.jena.rdf.model.Resource s, org.apache.jena.rdf.model.Property p, org.apache.jena.rdf.model.RDFNode o) Lists all model statements, which belong to the base graph, using the given SPO.static <R extends org.apache.jena.rdf.model.RDFNode>
org.apache.jena.util.iterator.ExtendedIterator<R>listMembers
(RDFNodeList<R> list) Lists all members fromOntology List
.static org.apache.jena.util.iterator.ExtendedIterator<OntStatement>
listSplitStatements
(OntStatement statement) Returns anExtendedIterator
over allOntology Statement
s, which are obtained from splitting the given statement into several equivalent ones but with disjoint annotations.static Stream<OntClass.Named>
Answers a stream of the named hierarchy roots of a given OntModel.static OntStatement
toOntStatement
(org.apache.jena.graph.Triple triple, OntModel model)
-
Constructor Details
-
OntModels
public OntModels()
-
-
Method Details
-
getOntType
Determines the actual ontology object type. -
asAnonymousIndividual
public static OntIndividual.Anonymous asAnonymousIndividual(org.apache.jena.rdf.model.RDFNode inModel) Creates an anonymous individual for the givenRDF Node
, that must be associated with a model. The result anonymous individual could be true (i.e. instance of some owl class) or fake (any blank node can be represented as it).- Parameters:
inModel
-RDFNode
, notnull
- Returns:
OntIndividual.Anonymous
- Throws:
OntJenaException
- if the node cannot be present as anonymous individual
-
listImports
Lists all imported models from the given one. -
listLocalObjects
public static <O extends OntObject> org.apache.jena.util.iterator.ExtendedIterator<O> listLocalObjects(OntModel model, Class<? extends O> type) Lists all ontology objects with the giventype
that are defined in the base graph. See alsolistLocalStatements(OntModel, Resource, Property, RDFNode)
description. -
listLocalEntities
public static org.apache.jena.util.iterator.ExtendedIterator<OntEntity> listLocalEntities(OntModel model) Lists all OWL entities that are defined in the base graph. See alsolistLocalStatements(OntModel, Resource, Property, RDFNode)
description. -
listMembers
public static <R extends org.apache.jena.rdf.model.RDFNode> org.apache.jena.util.iterator.ExtendedIterator<R> listMembers(RDFNodeList<R> list) Lists all members fromOntology List
.- Type Parameters:
R
-RDFNode
, a type of list members- Parameters:
list
-RDFNodeList
- Returns:
ExtendedIterator
ofR
-
listClasses
Lists all class-types for the given individual.- Parameters:
i
- anOntIndividual
, notnull
- Returns:
- an
ExtendedIterator
over all directclass
-types
-
listLocalStatements
public static org.apache.jena.util.iterator.ExtendedIterator<OntStatement> listLocalStatements(OntModel model, org.apache.jena.rdf.model.Resource s, org.apache.jena.rdf.model.Property p, org.apache.jena.rdf.model.RDFNode o) Lists all model statements, which belong to the base graph, using the given SPO.It is placed here because there is no certainty that methods for working with
ExtendedIterator
(likeOntGraphModelImpl.listLocalStatements(Resource, Property, RDFNode)
) should be placed in the public interfaces:Stream
-based analogues are almost the same but more functional. But the ability to work withExtendedIterator
is sometimes needed, since it is more lightweight and works a bit faster than Stream-API.- Parameters:
model
-OntModel
, notnull
s
-Resource
, can benull
for anyp
-Property
, can benull
for anyo
-RDFNode
, can benull
for any- Returns:
- an
ExtendedIterator
ofOntStatement
s local to the base model graph - See Also:
-
listAnnotations
public static org.apache.jena.util.iterator.ExtendedIterator<OntStatement> listAnnotations(OntStatement s) Returns an iterator over all direct annotations of the given ontology statement.- Parameters:
s
-OntStatement
- Returns:
ExtendedIterator
overOntStatement
s
-
listAnnotations
public static org.apache.jena.util.iterator.ExtendedIterator<OntStatement> listAnnotations(OntObject o) Lists all direct object's annotations.- Parameters:
o
-OntObject
, notnull
- Returns:
ExtendedIterator
overOntStatement
s
-
annotations
Recursively lists all annotations for the givenOntology Statement
in the form of a flat stream.- Parameters:
statement
-OntStatement
, notnull
- Returns:
- a
Stream
ofOntStatement
s, each of them is annotation property assertion - See Also:
-
listAllAnnotations
public static org.apache.jena.util.iterator.ExtendedIterator<OntStatement> listAllAnnotations(OntStatement statement) For the specifiedStatement
lists all its annotation assertions recursively including their sub-annotations.- Parameters:
statement
-OntStatement
, notnull
- Returns:
- an
ExtendedIterator
ofOntStatement
s - See Also:
-
getAllAnnotations
For the specifiedStatement
gets all its annotation assertions recursively including their sub-annotations.For example, for the following snippet
there would be three annotations:[ a owl:Annotation ; rdfs:label "label2" ; owl:annotatedProperty rdfs:label ; owl:annotatedSource [ a owl:Axiom ; rdfs:label "label1" ; owl:annotatedProperty rdfs:comment ; owl:annotatedSource [ a owl:Ontology ; rdfs:comment "comment" ] ; owl:annotatedTarget "comment" ] ; owl:annotatedTarget "label1" ] .
_:b0 rdfs:comment "comment"
,_:b1 rdfs:label "label1"
,_:b2 rdfs:label "label2"
.- Parameters:
statement
-OntStatement
, notnull
- Returns:
- an
Set
ofOntStatement
s
-
listSplitStatements
public static org.apache.jena.util.iterator.ExtendedIterator<OntStatement> listSplitStatements(OntStatement statement) Returns anExtendedIterator
over allOntology Statement
s, which are obtained from splitting the given statement into several equivalent ones but with disjoint annotations. Each of the returned statements is equal to the given, the difference is only in the related annotations.This method can be used in case there are several typed b-nodes for each annotation assertions instead of a single one. Such situation is not a canonical way and should not be widely used, since it is redundant. So usually the result stream contains only a single element: the same
OntStatement
instance as the input.The following code demonstrates that non-canonical way of writing annotations with two or more b-nodes:
Here the statements A t . _:b0 a owl:Axiom . _:b0 A1 t1 . _:b0 owl:annotatedSource s . _:b0 owl:annotatedProperty A . _:b0 owl:annotatedTarget t . _:b1 a owl:Axiom . _:b1 A2 t2 . _:b1 owl:annotatedSource s . _:b1 owl:annotatedProperty A . _:b1 owl:annotatedTarget t .
s A t
has two annotations, but they are spread over different resources (statements_:b0 A1 t1
and_:b1 A2 t2
). For this example, the method returns stream of twoOntStatement
s, and each of them has only one annotation. For generality, below is an example of the correct and equivalent way to write these annotations, which is the preferred since it is more compact:s A t . [ a owl:Axiom ; A1 t1 ; A2 t2 ; owl:annotatedProperty A ; owl:annotatedSource s ; owl:annotatedTarget t ] .
- Parameters:
statement
-OntStatement
, notnull
- Returns:
ExtendedIterator
ofOntStatement
s
-
toOntStatement
Answers anOntology Statement
in the specifiedmodel
that wraps the giventriple
. This method differs from the methodOntModel.asStatement(Triple)
in that it providesmain statement
if it is possible.- Parameters:
triple
-SPO
, notnull
model
-OntModel
, notnull
- Returns:
OntStatement
- See Also:
-
config
Gets model's config.- Parameters:
m
-OntModel
- Returns:
OntConfig
ornull
if model is notOntEnhGraph
-
namedHierarchyRoots
Answers a stream of the named hierarchy roots of a given OntModel. This will be similar to the results ofOntModel.hierarchyRoot()
, with the added constraint that every member of the returned stream will be a named class, not an anonymous class expression. The named root classes are calculated from the root classes by recursively replacing every anonymous class with its direct subclasses. Thus, it can be seen that the values in the stream consist of the shallowest fringe of named classes in the hierarchy.- Parameters:
m
-OntModel
- Returns:
- a
Stream
ofOntClass.Named
- See Also:
-
getLCA
Answers the lowest common ancestor of two classes. This is the class that is farthest from the root concept (defaulting toowl:Thing
which is a superclass of bothu
andv
). The algorithm is based on Tarjan's off-line LCA. The current implementation expects that the given model:- is transitively closed over the
subClassOf
relation - can cheaply determine direct sub-class relations
Both of these conditions are true of the built-in Jena OWL reasoners, such as
OntSpecification.OWL2_FULL_MEM_MICRO_RULES_INF
, and external DL reasoners such as Pellet. - is transitively closed over the
-
getLCA
Answers the lowest common ancestor of two classes, assuming that the given class is the root concept to start searching from. SeegetLCA(OntClass, OntClass)
for details.
-