java.lang.Object
org.apache.jena.graph.impl.GraphBase
- All Implemented Interfaces:
Graph
,GraphWithPerform
- Direct Known Subclasses:
BaseInfGraph
,CollectionGraph
,CompositionBase
,GraphMemBase
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
FieldsModifier and TypeFieldDescriptionstatic final int
toString will not cut off up to this number of triples.static final int
toString will not output more than this number of triples.Fields inherited from interface org.apache.jena.graph.Graph
emptyGraph
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a triple, and notify the event manager.void
clear()
Remove all the statements from this graph.void
close()
Close this graph.final boolean
Answertrue
if this graph contains(s, p, o)
; this canonical implementation cannot be over-ridden.final boolean
Answertrue
ifft
is in the graph as revealed byfind(t)
being non-empty.final void
Delete a triple, and notify the event manager.boolean
Default implementation answerstrue
iff this graph is the same graph as the argument graph.final ExtendedIterator<Triple>
Returns an iterator over Triples matching a pattern.final ExtendedIterator<Triple>
Returns an iterator over all the Triples that match the triple pattern.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).Answer the event manager for this graph; allocate a new one if required.Answer the PrefixMapping object for this graph, the same one each time.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.boolean
Answer true iff this graph is isomorphic tog
according to the algorithm (indeed, method) inGraphMatcher
.void
Tell the event manager that the triplet
has been added to the graph.void
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
Remove a triple from the triple store.void
Remove all triples that match by find(s, p, o)final int
size()
Answer the size of this graph (ie the number of exposed triples).toString()
Answer a human-consumable representation of this graph.static String
Answer a human-consumable representation ofthat
.
-
Field Details
-
TOSTRING_TRIPLE_BASE
public static final int TOSTRING_TRIPLE_BASEtoString will not cut off up to this number of triples.- See Also:
-
TOSTRING_TRIPLE_LIMIT
public static final int TOSTRING_TRIPLE_LIMITtoString will not output more than this number of triples.- See Also:
-
-
Constructor Details
-
GraphBase
public GraphBase()Initialise this graph as one with reification style Minimal.
-
-
Method Details
-
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
Default implementation answerstrue
iff this graph is the same graph as the argument graph. -
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
Tell the event manager that the triplet
has been added to the graph. -
notifyDelete
Tell the event manager that the triplet
has been deleted from the graph. -
getTransactionHandler
Answer a transaction handler bound to this graph. The default is SimpleTransactionHandler, which handles no transactions.- Specified by:
getTransactionHandler
in interfaceGraph
-
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
Answer the PrefixMapping object for this graph, the same one each time.- Specified by:
getPrefixMapping
in interfaceGraph
-
add
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
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
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
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. -
remove
Remove all triples that match by find(s, p, o) -
find
Description copied from interface:Graph
Returns an iterator over all the Triples that match the triple pattern. -
forTestingOnly_graphBaseFind
-
find
Description copied from interface:Graph
Returns an iterator over Triples matching a pattern. -
contains
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
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.- Specified by:
isEmpty
in interfaceGraph
- Implementation Note:
- The default implementation relies on
contains(Triple)
withTriple.ANY
as the argument. Subclasses may override if necessary.
-
isIsomorphicWith
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
Answer a human-consumable representation of this graph. Not advised for big graphs, as it generates a big string: intended for debugging purposes. -
toString
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).
-