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
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 inttoString will not cut off up to this number of triples.static final inttoString 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 TypeMethodDescriptionvoidAdd a triple, and notify the event manager.voidclear()Remove all the statements from this graph.voidclose()Close this graph.final booleanAnswertrueif this graph contains(s, p, o); this canonical implementation cannot be over-ridden.final booleanAnswertrueifftis in the graph as revealed byfind(t)being non-empty.final voidDelete a triple, and notify the event manager.booleanDefault implementation answerstrueiff 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.booleanisClosed()Answer true iff .close() has been called on this Graph.booleanisEmpty()Answer true iff this graph contains no triples (hidden reification quads do not count).booleanAnswer true iff this graph is isomorphic togaccording to the algorithm (indeed, method) inGraphMatcher.voidTell the event manager that the triplethas been added to the graph.voidTell the event manager that the triplethas been deleted from the graph.voidperformAdd(Triple t) Add a triple to the triple store.voidRemove a triple from the triple store.voidRemove all triples that match by find(s, p, o)final intsize()Answer the size of this graph (ie the number of exposed triples).toString()Answer a human-consumable representation of this graph.static StringAnswer 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:GraphAnswer true iff .close() has been called on this Graph. -
dependsOn
Default implementation answerstrueiff 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:
getEventManagerin interfaceGraph
-
notifyAdd
Tell the event manager that the triplethas been added to the graph. -
notifyDelete
Tell the event manager that the triplethas been deleted from the graph. -
getTransactionHandler
Answer a transaction handler bound to this graph. The default is SimpleTransactionHandler, which handles no transactions.- Specified by:
getTransactionHandlerin 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:
getCapabilitiesin interfaceGraph
-
getPrefixMapping
Answer the PrefixMapping object for this graph, the same one each time.- Specified by:
getPrefixMappingin 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:
performAddin 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:
performDeletein 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:GraphReturns an iterator over all the Triples that match the triple pattern. -
forTestingOnly_graphBaseFind
-
find
Description copied from interface:GraphReturns an iterator over Triples matching a pattern. -
contains
Answertrueifftis in the graph as revealed byfind(t)being non-empty.tmay contain ANY wildcards. Sub-classes may over-ride graphBaseContains for efficiency. -
contains
Answertrueif 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 ifsizeis reasonable efficient. Subclasses may override if necessary. This method may become final and defined in terms of other methods. -
isIsomorphicWith
Answer true iff this graph is isomorphic togaccording to the algorithm (indeed, method) inGraphMatcher.- Specified by:
isIsomorphicWithin 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 stringprefixwill 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).
-