- 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 OntEnhGraph
asPersonalityModel
(org.apache.jena.enhanced.EnhGraph graph) Represents the givenEnhGraph
as aOntEnhGraph
.static OntEnhGraph
asPersonalityModel
(OntModel graph) Represents the givenOnt[Graph]Model
as aOntEnhGraph
.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 givennode
can be viewed as the given type.default boolean
Equivalent tosafeFindNodeAs(node, view) != null
.default <X extends OntObject>
voidstatic OntConfig
config
(org.apache.jena.enhanced.EnhGraph graph) ExtractsOntConfig
from 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 givennode
and conforms to the given interface type.<N extends org.apache.jena.rdf.model.RDFNode>
NAnswers an enhanced node that wraps the givennode
and 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 givennode
and 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 givenEnhGraph
as 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]Model
as 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
ExtractsOntConfig
from 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 givennode
can be viewed as the given type. Opposite to the methodfindNodeAs(Node, Class)
, this method handles possible graph recursions.- Parameters:
view
- Class-typenode
-Node
graph
-EnhGraph
, assumed to beOntGraphModelImpl
- Returns:
true
if 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 givennode
and 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 givennode
and conforms to the given interface type. It works silently: no exception is thrown, instead returnsnull
.- Type Parameters:
N
- any subtype ofRDFNode
- Parameters:
node
-Node
type
-Class
-type- Returns:
RDFNode
ornull
- 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 givennode
and 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
null
if 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
-RDFNode
typenode
-Node
- Returns:
- boolean
-
checkType
- Type Parameters:
X
- anyOntObject
type- Parameters:
type
-X
- Throws:
OntJenaException.Unsupported
- if thetype
is not supported by the configuration
-