- All Known Implementing Classes:
OntGraphModelImpl
public interface OntEnhGraph
An abstraction to work with
OntPersonality
and an interface-analogue of the Jena Enhanced Graph,
and also a facility to provide implicit links between different
EnhNodeFactory factories within a model.
A .orElse(null) is assumed to be OntEnhGraph.
Explicit links between object factories are undesirable, since replacing one of the factories will affect others.
But using this interface, it is possible to build safe implicit links and
replacing one factory with a custom implementation will not break the whole model.
More about this see in the description for
the method OntObjectPersonalityBuilder.add(Class, EnhNodeFactory).
-
Method Summary
Modifier and TypeMethodDescriptionstatic OntEnhGraphasPersonalityModel(org.apache.jena.enhanced.EnhGraph graph) Represents the givenEnhGraphas aOntEnhGraph.static OntEnhGraphasPersonalityModel(OntModel graph) Represents the givenOnt[Graph]Modelas aOntEnhGraph.static booleancanAs(Class<? extends org.apache.jena.rdf.model.RDFNode> view, org.apache.jena.graph.Node node, org.apache.jena.enhanced.EnhGraph graph) Checks if the givennodecan be viewed as the given type.default booleanEquivalent tosafeFindNodeAs(node, view) != null.default <X extends OntObject>
voidstatic OntConfigconfig(org.apache.jena.enhanced.EnhGraph graph) ExtractsOntConfigfrom the given enhanced graph.<N extends org.apache.jena.rdf.model.RDFNode>
NfindNodeAs(org.apache.jena.graph.Node node, Class<N> type) Answers an enhanced node that wraps the givennodeand conforms to the given interface type.<N extends org.apache.jena.rdf.model.RDFNode>
NAnswers an enhanced node that wraps the givennodeand conforms to the given interface type.Returns the model personality, that is unmodifiable model's configuration storage.<N extends org.apache.jena.rdf.model.RDFNode>
NsafeFindNodeAs(org.apache.jena.graph.Node node, Class<N> view) Answers an enhanced node that wraps the givennodeand conforms to the given interface type, taking into account possible graph recursions.
-
Method Details
-
asPersonalityModel
static OntEnhGraph asPersonalityModel(org.apache.jena.enhanced.EnhGraph graph) throws OntJenaException Represents the givenEnhGraphas aOntEnhGraph.- Parameters:
graph-enhanced graph, that is also assumed to beOntModel, notnull- Returns:
OntEnhGraph- Throws:
OntJenaException- in case the conversion is not possible- See Also:
-
asPersonalityModel
Represents the givenOnt[Graph]Modelas aOntEnhGraph.- Parameters:
graph-OWL graph model, that is also assumed to beEnhGraph, notnull- Returns:
OntEnhGraph- Throws:
OntJenaException- in case the conversion is not possible- See Also:
-
config
ExtractsOntConfigfrom the given enhanced graph.- Parameters:
graph-OWL graph model, that is also assumed to beEnhGraph, notnull- Returns:
OntConfig
-
canAs
static boolean canAs(Class<? extends org.apache.jena.rdf.model.RDFNode> view, org.apache.jena.graph.Node node, org.apache.jena.enhanced.EnhGraph graph) Checks if the givennodecan be viewed as the given type. Opposite to the methodfindNodeAs(Node, Class), this method handles possible graph recursions.- Parameters:
view- Class-typenode-Nodegraph-EnhGraph, assumed to beOntGraphModelImpl- Returns:
trueif the node can be safely cast to the specified type
-
getOntPersonality
OntPersonality getOntPersonality()Returns the model personality, that is unmodifiable model's configuration storage.- Returns:
OntPersonality
-
getNodeAs
<N extends org.apache.jena.rdf.model.RDFNode> N getNodeAs(org.apache.jena.graph.Node node, Class<N> view) Answers an enhanced node that wraps the givennodeand conforms to the given interface type.- Type Parameters:
N- a subtype ofRDFNode- Parameters:
node- anode, that is assumed to be in this graphview- a type denoting the enhanced facet desired- Returns:
- an enhanced node, not
null - Throws:
OntJenaException- in case no RDFNode match found- See Also:
-
findNodeAs(Node, Class)EnhGraph.getNodeAs(Node, Class)
-
findNodeAs
<N extends org.apache.jena.rdf.model.RDFNode> N findNodeAs(org.apache.jena.graph.Node node, Class<N> type) Answers an enhanced node that wraps the givennodeand conforms to the given interface type. It works silently: no exception is thrown, instead returnsnull.- Type Parameters:
N- any subtype ofRDFNode- Parameters:
node-Nodetype-Class-type- Returns:
RDFNodeornull- See Also:
-
safeFindNodeAs
<N extends org.apache.jena.rdf.model.RDFNode> N safeFindNodeAs(org.apache.jena.graph.Node node, Class<N> view) Answers an enhanced node that wraps the givennodeand conforms to the given interface type, taking into account possible graph recursions.- Type Parameters:
N- a subtype ofRDFNode- Parameters:
node- anode, that is assumed to be in this graphview- a type denoting the enhanced facet desired- Returns:
- an enhanced node or
nullif no match found - Throws:
OntJenaException.Recursion- if a graph recursion is indicated- See Also:
-
canNodeAs
default boolean canNodeAs(Class<? extends org.apache.jena.rdf.model.RDFNode> view, org.apache.jena.graph.Node node) Equivalent tosafeFindNodeAs(node, view) != null.- Parameters:
view-RDFNodetypenode-Node- Returns:
- boolean
-
checkType
- Type Parameters:
X- anyOntObjecttype- Parameters:
type-X- Throws:
OntJenaException.Unsupported- if thetypeis not supported by the configuration
-