Package org.apache.jena.graph.impl
Class GraphBase
- java.lang.Object
-
- org.apache.jena.graph.impl.GraphBase
-
- All Implemented Interfaces:
Graph
,GraphWithPerform
- Direct Known Subclasses:
BaseInfGraph
,CollectionGraph
,CompositionBase
,GraphMemBase
public abstract class GraphBase extends java.lang.Object implements GraphWithPerform
GraphBase is an implementation of Graph that provides some convenient base functionality for Graph implementations.Subtypes of GraphBase must provide performAdd(Triple), performDelete(Triple), graphBaseFind(TripleMatch,TripleAction), and graphBaseSize(). GraphBase provides default implementations of the other methods, including the other finds (on top of that one), a simple-minded prepare, and contains. GraphBase also handles the event-listening and registration interfaces.
When a GraphBase is closed, future operations on it may throw an exception.
-
-
Field Summary
Fields Modifier and Type Field Description static int
TOSTRING_TRIPLE_BASE
toString will not cut off up to this number of triples.static int
TOSTRING_TRIPLE_LIMIT
toString will not output more than this number of triples.-
Fields inherited from interface org.apache.jena.graph.Graph
emptyGraph
-
-
Constructor Summary
Constructors Constructor Description GraphBase()
Initialise this graph as one with reification style Minimal.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Triple t)
Add a triple, and notify the event manager.void
clear()
Remove all the statements from this graph.void
close()
Close this graph.boolean
contains(Node s, Node p, Node o)
Answertrue
if this graph contains(s, p, o)
; this canonical implementation cannot be over-ridden.boolean
contains(Triple t)
Answertrue
ifft
is in the graph as revealed byfind(t)
being non-empty.void
delete(Triple t)
Delete a triple, and notify the event manager.boolean
dependsOn(Graph other)
Default implementation answerstrue
iff this graph is the same graph as the argument graph.ExtendedIterator<Triple>
find(Node s, Node p, Node o)
Returns an iterator over Triples matching a pattern.ExtendedIterator<Triple>
find(Triple m)
Returns an iterator over all the Triples that match the triple pattern.ExtendedIterator<Triple>
forTestingOnly_graphBaseFind(Triple t)
Capabilities
getCapabilities()
Answer the capabilities of this graph; the default is an AllCapabilities object (the same one each time, not that it matters - Capabilities should be immutable).GraphEventManager
getEventManager()
Answer the event manager for this graph; allocate a new one if required.PrefixMapping
getPrefixMapping()
Answer the PrefixMapping object for this graph, the same one each time.TransactionHandler
getTransactionHandler()
Answer a transaction handler bound to this graph.boolean
isClosed()
Answer true iff .close() has been called on this Graph.boolean
isEmpty()
Answer true iff this graph contains no triples (hidden reification quads do not count).boolean
isIsomorphicWith(Graph g)
Answer true iff this graph is isomorphic tog
according to the algorithm (indeed, method) inGraphMatcher
.void
notifyAdd(Triple t)
Tell the event manager that the triplet
has been added to the graph.void
notifyDelete(Triple t)
Tell the event manager that the triplet
has been deleted from the graph.void
performAdd(Triple t)
Add a triple to the triple store.void
performDelete(Triple t)
Remove a triple from the triple store.void
remove(Node s, Node p, Node o)
Remove all triples that match by find(s, p, o)int
size()
Answer the size of this graph (ie the number of exposed triples).java.lang.String
toString()
Answer a human-consumable representation of this graph.static java.lang.String
toString(java.lang.String prefix, Graph that)
Answer a human-consumable representation ofthat
.
-
-
-
Field Detail
-
TOSTRING_TRIPLE_BASE
public static final int TOSTRING_TRIPLE_BASE
toString will not cut off up to this number of triples.- See Also:
- Constant Field Values
-
TOSTRING_TRIPLE_LIMIT
public static final int TOSTRING_TRIPLE_LIMIT
toString will not output more than this number of triples.- See Also:
- Constant Field Values
-
-
Method Detail
-
close
public void close()
Close this graph. Subgraphs may extend to discard resources.
-
isClosed
public boolean isClosed()
Description copied from interface:Graph
Answer true iff .close() has been called on this Graph.
-
dependsOn
public boolean dependsOn(Graph other)
Default implementation answerstrue
iff this graph is the same graph as the argument graph.
-
getEventManager
public GraphEventManager getEventManager()
Answer the event manager for this graph; allocate a new one if required. Subclasses may override if they have a more specialised event handler. The default is a SimpleEventManager.- Specified by:
getEventManager
in interfaceGraph
-
notifyAdd
public void notifyAdd(Triple t)
Tell the event manager that the triplet
has been added to the graph.
-
notifyDelete
public void notifyDelete(Triple t)
Tell the event manager that the triplet
has been deleted from the graph.
-
getTransactionHandler
public TransactionHandler getTransactionHandler()
Answer a transaction handler bound to this graph. The default is SimpleTransactionHandler, which handles no transactions.- Specified by:
getTransactionHandler
in interfaceGraph
-
getCapabilities
public Capabilities getCapabilities()
Answer the capabilities of this graph; the default is an AllCapabilities object (the same one each time, not that it matters - Capabilities should be immutable).- Specified by:
getCapabilities
in interfaceGraph
-
getPrefixMapping
public PrefixMapping getPrefixMapping()
Answer the PrefixMapping object for this graph, the same one each time.- Specified by:
getPrefixMapping
in interfaceGraph
-
add
public void add(Triple t)
Add a triple, and notify the event manager. Subclasses should not need to override this - we might make it final. The triple is added using performAdd, and notification done by notifyAdd.
-
performAdd
public void performAdd(Triple t)
Add a triple to the triple store. The default implementation throws an AddDeniedException; subclasses must override if they want to be able to add triples.- Specified by:
performAdd
in interfaceGraphWithPerform
-
delete
public final void delete(Triple t)
Delete a triple, and notify the event manager. Subclasses should not need to override this - we might make it final. The triple is added using performDelete, and notification done by notifyDelete.
-
performDelete
public void performDelete(Triple t)
Remove a triple from the triple store. The default implementation throws a DeleteDeniedException; subclasses must override if they want to be able to remove triples.- Specified by:
performDelete
in interfaceGraphWithPerform
-
clear
public void clear()
Remove all the statements from this graph.
-
find
public final ExtendedIterator<Triple> find(Triple m)
Description copied from interface:Graph
Returns an iterator over all the Triples that match the triple pattern.
-
forTestingOnly_graphBaseFind
public ExtendedIterator<Triple> forTestingOnly_graphBaseFind(Triple t)
-
find
public final ExtendedIterator<Triple> find(Node s, Node p, Node o)
Description copied from interface:Graph
Returns an iterator over Triples matching a pattern.
-
contains
public final boolean contains(Triple t)
Answertrue
ifft
is in the graph as revealed byfind(t)
being non-empty.t
may contain ANY wildcards. Sub-classes may over-ride graphBaseContains for efficiency.
-
contains
public final boolean contains(Node s, Node p, Node o)
Answertrue
if this graph contains(s, p, o)
; this canonical implementation cannot be over-ridden.
-
size
public final int size()
Answer the size of this graph (ie the number of exposed triples). Defined as the size of the triple store plus the size of the reification store. Subclasses must override graphBaseSize() to reimplement (and reifierSize if they have some special reason for redefined that).
-
isEmpty
public boolean isEmpty()
Answer true iff this graph contains no triples (hidden reification quads do not count). The default implementation issize() == 0
, which is fine ifsize
is reasonable efficient. Subclasses may override if necessary. This method may become final and defined in terms of other methods.
-
isIsomorphicWith
public boolean isIsomorphicWith(Graph g)
Answer true iff this graph is isomorphic tog
according to the algorithm (indeed, method) inGraphMatcher
.- Specified by:
isIsomorphicWith
in interfaceGraph
- Parameters:
g
- Compare against this.- Returns:
- boolean True if the two graphs are isomorphic.
-
toString
public java.lang.String toString()
Answer a human-consumable representation of this graph. Not advised for big graphs, as it generates a big string: intended for debugging purposes.- Overrides:
toString
in classjava.lang.Object
-
toString
public static java.lang.String toString(java.lang.String prefix, Graph that)
Answer a human-consumable representation ofthat
. The stringprefix
will appear near the beginning of the string. Nodes may be prefix-compressed usingthat
's prefix-mapping. This default implementation will display all the triples exposed by the graph (ie including reification triples if it is Standard).
-
-