- 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
Nested ClassesModifier and TypeClassDescriptionstatic classAn extendedJena Graph Event Manager, a holder forGraphListeners.static classA 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_LIMITFields inherited from interface org.apache.jena.graph.Graph
emptyGraph -
Constructor Summary
ConstructorsConstructorDescriptionUnionGraphImpl(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.voidclear()voidclose()Closes the graph including all related graphs.booleandependsOn(org.apache.jena.graph.Graph other) Generic dependsOn, returnstrueiff this graph or any sub-graphs depend on the specified graph.org.apache.jena.graph.GraphReturns the base (primary) graph.Answers the ont event manager for this graph.org.apache.jena.shared.PrefixMappingReturns the underlying graph, possible empty.booleangraphBaseContains(org.apache.jena.graph.Triple t) Answerstrueif the graph contains any triple matchingt.intbooleanAnswerstrueiff thisUnionGraphhas sub-graphs.booleanAnswerstrueiff this graph is distinct.booleanisEmpty()org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Graph>Lists all indivisible (base) dataGraphs that are encapsulated either in the hierarchy or (which is possible) inside thebase(root) graph itself.voidperformAdd(org.apache.jena.graph.Triple t) voidperformDelete(org.apache.jena.graph.Triple t) voidremove(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, rejectingMethods inherited from class org.apache.jena.graph.impl.GraphBase
add, contains, contains, delete, find, find, forTestingOnly_graphBaseFind, getTransactionHandler, isClosed, isIsomorphicWith, notifyAdd, notifyDelete, size, toStringMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.jena.graph.Graph
add, add, contains, contains, delete, delete, find, find, find, getCapabilities, getTransactionHandler, isClosed, isIsomorphicWith, size, sizeLong, stream, streamMethods 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
distinctistrue). 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, notnulldistinct- iftruea 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, notnulleventManager-UnionGraph.EventManagerornullto use default fresh event managerdistinct- iftruea distinct graph is created
-
-
Method Details
-
getPrefixMapping
public org.apache.jena.shared.PrefixMapping getPrefixMapping()- Specified by:
getPrefixMappingin interfaceorg.apache.jena.graph.Graph- Overrides:
getPrefixMappingin classorg.apache.jena.graph.impl.GraphBase
-
getEventManager
Answers the ont event manager for this graph. Override to use inGraphBase.add(Triple).- Specified by:
getEventManagerin interfaceorg.apache.jena.graph.Graph- Specified by:
getEventManagerin interfaceUnionGraph- Overrides:
getEventManagerin classorg.apache.jena.graph.impl.GraphBase- Returns:
GraphEventManager, notnull
-
isDistinct
public boolean isDistinct()Answerstrueiff this graph is distinct. SeeUnionGraphImpl(Graph)description.- Specified by:
isDistinctin interfaceUnionGraph- Returns:
- boolean
-
getBaseGraph
public org.apache.jena.graph.Graph getBaseGraph()Returns the base (primary) graph.- Specified by:
getBaseGraphin interfaceUnionGraph- Returns:
Graph, notnull
-
getSubGraphs
Returns the underlying graph, possible empty.- Returns:
UnionGraphImpl.SubGraphs, notnull
-
hasSubGraph
public boolean hasSubGraph()Description copied from interface:UnionGraphAnswerstrueiff thisUnionGraphhas sub-graphs.- Specified by:
hasSubGraphin interfaceUnionGraph- Returns:
- boolean
-
subGraphs
Description copied from interface:UnionGraphLists all sub-graphs. Thebase graphis not included in the result.- Specified by:
subGraphsin interfaceUnionGraph- Returns:
Streamof sub-graphs
-
superGraphs
Description copied from interface:UnionGraphLists all parent graphs. Thebase graphis not included in the result.- Specified by:
superGraphsin interfaceUnionGraph- Returns:
Streamof sub-graphs
-
performAdd
public void performAdd(org.apache.jena.graph.Triple t) - Specified by:
performAddin interfaceorg.apache.jena.graph.impl.GraphWithPerform- Overrides:
performAddin classorg.apache.jena.graph.impl.GraphBase
-
performDelete
public void performDelete(org.apache.jena.graph.Triple t) - Specified by:
performDeletein interfaceorg.apache.jena.graph.impl.GraphWithPerform- Overrides:
performDeletein 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:
removein interfaceorg.apache.jena.graph.Graph- Overrides:
removein classorg.apache.jena.graph.impl.GraphBase
-
clear
public void clear()- Specified by:
clearin interfaceorg.apache.jena.graph.Graph- Overrides:
clearin classorg.apache.jena.graph.impl.GraphBase
-
addSubGraph
Adds the specified graph to the underlying graph collection. Note: for a well-formed ontologicalUnionGraphthe inputgraphmust be also aUnionGraph, even it has no hierarchy structure.- Specified by:
addSubGraphin interfaceUnionGraph- Parameters:
graph-Graph, notnull- Returns:
- this instance
-
removeSubGraph
Removes the specified graph from the underlying graph collection.- Specified by:
removeSubGraphin 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) dataGraphs that are encapsulated either in the hierarchy or (which is possible) inside thebase(root) graph itself.- Returns:
- distinct
ExtendedIteratorofGraphs, including the base graph - See Also:
-
graphBaseContains
public boolean graphBaseContains(org.apache.jena.graph.Triple t) Answerstrueif 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:
isEmptyin interfaceorg.apache.jena.graph.Graph- Overrides:
isEmptyin 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:
closein interfaceorg.apache.jena.graph.Graph- Overrides:
closein classorg.apache.jena.graph.impl.GraphBase
-
dependsOn
public boolean dependsOn(org.apache.jena.graph.Graph other) Generic dependsOn, returnstrueiff this graph or any sub-graphs depend on the specified graph.- Specified by:
dependsOnin interfaceorg.apache.jena.graph.Graph- Overrides:
dependsOnin classorg.apache.jena.graph.impl.GraphBase- Parameters:
other-Graph- Returns:
- boolean
-
toString
- Overrides:
toStringin classorg.apache.jena.graph.impl.GraphBase
-