- All Implemented Interfaces:
org.apache.jena.graph.Graph
,org.apache.jena.graph.impl.GraphWithPerform
,UnionGraph
It consists of two parts: a base graph
and an sub-graphs
collection.
Unlike MultiUnion
this implementation explicitly requires primary (base) graph.
Underlying sub-graphs are only used for searching; modify operations are performed only on the base graph.
This graph allows building graph hierarchy which can be used to link different models.
Also, it allows recursion, that is, it can contain itself somewhere in the hierarchy.
The PrefixMapping
of this graph is taken from the base graph,
and, therefore, any changes in it reflect both the base and this graph.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An extendedJena Graph Event Manager
, a holder forGraphListener
s.static class
A container to hold all sub-graphs, that make up the hierarchy.Nested classes/interfaces inherited from interface org.apache.jena.ontapi.UnionGraph
UnionGraph.EventManager, UnionGraph.Listener
-
Field Summary
Fields inherited from class org.apache.jena.graph.impl.GraphBase
TOSTRING_TRIPLE_BASE, TOSTRING_TRIPLE_LIMIT
Fields inherited from interface org.apache.jena.graph.Graph
emptyGraph
-
Constructor Summary
ConstructorDescriptionUnionGraphImpl
(org.apache.jena.graph.Graph base) Creates an instance with default settings.UnionGraphImpl
(org.apache.jena.graph.Graph base, boolean distinct) Creates a graph for the givenbase
, which will be either distinct or non-distinct, depending on the second parameter.UnionGraphImpl
(org.apache.jena.graph.Graph base, UnionGraph.EventManager eventManager, boolean distinct) Creates a graph for the givenbase
. -
Method Summary
Modifier and TypeMethodDescriptionaddSubGraph
(org.apache.jena.graph.Graph graph) Adds the specified graph to the underlying graph collection.void
clear()
void
close()
Closes the graph including all related graphs.boolean
dependsOn
(org.apache.jena.graph.Graph other) Generic dependsOn, returnstrue
iff this graph or any sub-graphs depend on the specified graph.org.apache.jena.graph.Graph
Returns the base (primary) graph.Answers the ont event manager for this graph.org.apache.jena.shared.PrefixMapping
Returns the underlying graph, possible empty.boolean
graphBaseContains
(org.apache.jena.graph.Triple t) Answerstrue
if the graph contains any triple matchingt
.int
boolean
Answerstrue
iff thisUnionGraph
has sub-graphs.boolean
Answerstrue
iff this graph is distinct.boolean
isEmpty()
org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Graph>
Lists all indivisible (base) dataGraph
s that are encapsulated either in the hierarchy or (which is possible) inside thebase
(root) graph itself.void
performAdd
(org.apache.jena.graph.Triple t) void
performDelete
(org.apache.jena.graph.Triple t) void
remove
(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o) removeSubGraph
(org.apache.jena.graph.Graph graph) Removes the specified graph from the underlying graph collection.Stream<org.apache.jena.graph.Graph>
Lists all sub-graphs.Lists all parent graphs.toString()
Methods inherited from class org.apache.jena.graph.compose.CompositionBase
butNot, ifIn, ifIn, recording, reject, rejecting, rejecting
Methods inherited from class org.apache.jena.graph.impl.GraphBase
add, contains, contains, delete, find, find, forTestingOnly_graphBaseFind, getCapabilities, getTransactionHandler, isClosed, isIsomorphicWith, notifyAdd, notifyDelete, size, toString
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.jena.graph.Graph
add, add, contains, contains, delete, delete, find, find, find, getCapabilities, getTransactionHandler, isClosed, isIsomorphicWith, size, sizeLong, stream, stream
Methods inherited from interface org.apache.jena.ontapi.UnionGraph
addSubGraphIfAbsent, contains
-
Constructor Details
-
UnionGraphImpl
public UnionGraphImpl(org.apache.jena.graph.Graph base) Creates an instance with default settings.Note: it results a distinct graph (i.e. its parameter
distinct
istrue
). This means that the methodGraphBase.find(Triple)
does not produce duplicates. The additional duplicate checking may lead to temporary writing the whole graph or some its part into memory in the form ofSet
, and for huge ontologies it is unacceptable. This checking is not performed if the graph is single (the underlying part is empty).Also notice, a top-level ontology view of in-memory graph is not sensitive to the distinct parameter since it uses only base graphs to collect axiomatic data.
- Parameters:
base
-Graph
, notnull
-
UnionGraphImpl
public UnionGraphImpl(org.apache.jena.graph.Graph base, boolean distinct) Creates a graph for the givenbase
, which will be either distinct or non-distinct, depending on the second parameter. Other settings are default.- Parameters:
base
-Graph
, notnull
distinct
- iftrue
a distinct graph is created
-
UnionGraphImpl
public UnionGraphImpl(org.apache.jena.graph.Graph base, UnionGraph.EventManager eventManager, boolean distinct) Creates a graph for the givenbase
.- Parameters:
base
-Graph
, notnull
eventManager
-UnionGraph.EventManager
ornull
to use default fresh event managerdistinct
- iftrue
a distinct graph is created
-
-
Method Details
-
getPrefixMapping
public org.apache.jena.shared.PrefixMapping getPrefixMapping()- Specified by:
getPrefixMapping
in interfaceorg.apache.jena.graph.Graph
- Overrides:
getPrefixMapping
in classorg.apache.jena.graph.impl.GraphBase
-
getEventManager
Answers the ont event manager for this graph. Override to use inGraphBase.add(Triple)
.- Specified by:
getEventManager
in interfaceorg.apache.jena.graph.Graph
- Specified by:
getEventManager
in interfaceUnionGraph
- Overrides:
getEventManager
in classorg.apache.jena.graph.impl.GraphBase
- Returns:
GraphEventManager
, notnull
-
isDistinct
public boolean isDistinct()Answerstrue
iff this graph is distinct. SeeUnionGraphImpl(Graph)
description.- Specified by:
isDistinct
in interfaceUnionGraph
- Returns:
- boolean
-
getBaseGraph
public org.apache.jena.graph.Graph getBaseGraph()Returns the base (primary) graph.- Specified by:
getBaseGraph
in interfaceUnionGraph
- Returns:
Graph
, notnull
-
getSubGraphs
Returns the underlying graph, possible empty.- Returns:
UnionGraphImpl.SubGraphs
, notnull
-
hasSubGraph
public boolean hasSubGraph()Description copied from interface:UnionGraph
Answerstrue
iff thisUnionGraph
has sub-graphs.- Specified by:
hasSubGraph
in interfaceUnionGraph
- Returns:
- boolean
-
subGraphs
Description copied from interface:UnionGraph
Lists all sub-graphs. Thebase graph
is not included in the result.- Specified by:
subGraphs
in interfaceUnionGraph
- Returns:
Stream
of sub-graph
s
-
superGraphs
Description copied from interface:UnionGraph
Lists all parent graphs. Thebase graph
is not included in the result.- Specified by:
superGraphs
in interfaceUnionGraph
- Returns:
Stream
of sub-graph
s
-
performAdd
public void performAdd(org.apache.jena.graph.Triple t) - Specified by:
performAdd
in interfaceorg.apache.jena.graph.impl.GraphWithPerform
- Overrides:
performAdd
in classorg.apache.jena.graph.impl.GraphBase
-
performDelete
public void performDelete(org.apache.jena.graph.Triple t) - Specified by:
performDelete
in interfaceorg.apache.jena.graph.impl.GraphWithPerform
- Overrides:
performDelete
in classorg.apache.jena.graph.impl.GraphBase
-
remove
public void remove(org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o) - Specified by:
remove
in interfaceorg.apache.jena.graph.Graph
- Overrides:
remove
in classorg.apache.jena.graph.impl.GraphBase
-
clear
public void clear()- Specified by:
clear
in interfaceorg.apache.jena.graph.Graph
- Overrides:
clear
in classorg.apache.jena.graph.impl.GraphBase
-
addSubGraph
Adds the specified graph to the underlying graph collection. Note: for a well-formed ontologicalUnionGraph
the inputgraph
must be also aUnionGraph
, even it has no hierarchy structure.- Specified by:
addSubGraph
in interfaceUnionGraph
- Parameters:
graph
-Graph
, notnull
- Returns:
- this instance
-
removeSubGraph
Removes the specified graph from the underlying graph collection.- Specified by:
removeSubGraph
in interfaceUnionGraph
- Parameters:
graph
-Graph
, notnull
- Returns:
- this instance
-
listSubGraphBases
public org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Graph> listSubGraphBases()Lists all indivisible (base) dataGraph
s that are encapsulated either in the hierarchy or (which is possible) inside thebase
(root) graph itself.- Returns:
- distinct
ExtendedIterator
ofGraph
s, including the base graph - See Also:
-
graphBaseContains
public boolean graphBaseContains(org.apache.jena.graph.Triple t) Answerstrue
if the graph contains any triple matchingt
.- Parameters:
t
-Triple
, notnull
- Returns:
- boolean
- See Also:
-
MultiUnion.graphBaseContains(Triple)
-
graphBaseSize
public int graphBaseSize() -
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceorg.apache.jena.graph.Graph
- Overrides:
isEmpty
in classorg.apache.jena.graph.impl.GraphBase
-
close
public void close()Closes the graph including all related graphs. Caution: this is an irreversible operation, once closed, a graph cannot be reopened.- Specified by:
close
in interfaceorg.apache.jena.graph.Graph
- Overrides:
close
in classorg.apache.jena.graph.impl.GraphBase
-
dependsOn
public boolean dependsOn(org.apache.jena.graph.Graph other) Generic dependsOn, returnstrue
iff this graph or any sub-graphs depend on the specified graph.- Specified by:
dependsOn
in interfaceorg.apache.jena.graph.Graph
- Overrides:
dependsOn
in classorg.apache.jena.graph.impl.GraphBase
- Parameters:
other
-Graph
- Returns:
- boolean
-
toString
- Overrides:
toString
in classorg.apache.jena.graph.impl.GraphBase
-