Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.hp.hpl.jena.graph.impl
Class GraphBase  view GraphBase download GraphBase.java

java.lang.Object
  extended bycom.hp.hpl.jena.graph.impl.GraphBase
All Implemented Interfaces:
com.hp.hpl.jena.graph.Graph, com.hp.hpl.jena.graph.GraphAdd, GraphWithPerform
Direct Known Subclasses:
com.hp.hpl.jena.mem.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
protected  com.hp.hpl.jena.graph.BulkUpdateHandler bulkHandler
          The allocated BulkUpdateHandler, or null if no handler has been allocated yet.
protected  com.hp.hpl.jena.graph.Capabilities capabilities
          The allocated Capabilities object, or null if unallocated.
protected  boolean closed
          Whether or not this graph has been closed - used to report ClosedExceptions when an operation is attempted on a closed graph.
protected  com.hp.hpl.jena.graph.GraphEventManager gem
          The event manager that this Graph uses to, well, manage events; allocated on demand.
protected  com.hp.hpl.jena.shared.PrefixMapping pm
           
protected  com.hp.hpl.jena.graph.query.QueryHandler queryHandler
          The query handler for this graph, or null if queryHandler() has not been called yet.
protected  com.hp.hpl.jena.graph.Reifier reifier
          The cache variable for the allocated Reifier.
protected  com.hp.hpl.jena.shared.ReificationStyle style
          The reification style of this graph, used when the reifier is created (and nowhere else, as it happens, which is good).
 
Fields inherited from interface com.hp.hpl.jena.graph.Graph
emptyGraph
 
Constructor Summary
GraphBase()
          Initialise this graph as one with reification style Minimal.
GraphBase(com.hp.hpl.jena.shared.ReificationStyle style)
          Initialise this graph with the given reification style (which will be supplied to the reifier when it is created).
 
Method Summary
 void add(com.hp.hpl.jena.graph.Triple t)
          Add a triple, and notify the event manager.
protected  void checkOpen()
          Utility method: throw a ClosedException if this graph has been closed.
 void close()
          Close this graph.
 boolean contains(com.hp.hpl.jena.graph.Node s, com.hp.hpl.jena.graph.Node p, com.hp.hpl.jena.graph.Node o)
          Answer true if this graph contains (s, p, o); this canonical implementation cannot be over-ridden.
 boolean contains(com.hp.hpl.jena.graph.Triple t)
          Answer true iff t is in the graph as revealed by find(t) being non-empty.
protected  boolean containsByFind(com.hp.hpl.jena.graph.Triple t)
          Utility method: answer true iff we can find at least one instantiation of the triple in this graph using find(TripleMatch).
 void delete(com.hp.hpl.jena.graph.Triple t)
          Delete a triple, and notify the event manager.
 boolean dependsOn(com.hp.hpl.jena.graph.Graph other)
          Default implemenentation answers true iff this graph is the same graph as the argument graph.
 com.hp.hpl.jena.util.iterator.ExtendedIterator find(com.hp.hpl.jena.graph.Node s, com.hp.hpl.jena.graph.Node p, com.hp.hpl.jena.graph.Node o)
          Returns an iterator over Triple.
 com.hp.hpl.jena.util.iterator.ExtendedIterator find(com.hp.hpl.jena.graph.TripleMatch m)
          Answer an (extended) iterator over all the triples in this Graph matching m.
 com.hp.hpl.jena.graph.BulkUpdateHandler getBulkUpdateHandler()
          Answer a BulkUpdateHandler bound to this graph.
 com.hp.hpl.jena.graph.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).
 com.hp.hpl.jena.graph.GraphEventManager getEventManager()
          Answer the event manager for this graph; allocate a new one if required.
 com.hp.hpl.jena.shared.PrefixMapping getPrefixMapping()
          Answer the PrefixMapping object for this graph, the same one each time.
 com.hp.hpl.jena.graph.Reifier getReifier()
          Answer this graph's reifier.
 com.hp.hpl.jena.graph.TransactionHandler getTransactionHandler()
          Answer a transaction handler bound to this graph.
protected  boolean graphBaseContains(com.hp.hpl.jena.graph.Triple t)
          Answer true if the graph contains any triple matching t.
protected  com.hp.hpl.jena.util.iterator.ExtendedIterator graphBaseFind(com.hp.hpl.jena.graph.Node s, com.hp.hpl.jena.graph.Node p, com.hp.hpl.jena.graph.Node o)
           
protected abstract  com.hp.hpl.jena.util.iterator.ExtendedIterator graphBaseFind(com.hp.hpl.jena.graph.TripleMatch m)
          Answer an iterator over all the triples held in this graph's non-reified triple store that match m.
protected  int graphBaseSize()
          Answer the number of triples in this graph.
 boolean isEmpty()
          Answer true iff this graph contains no triples (hidden reification quads do not count).
 boolean isIsomorphicWith(com.hp.hpl.jena.graph.Graph g)
          Answer true iff this graph is isomorphic to g according to the algorithm (indeed, method) in GraphMatcher.
 void notifyAdd(com.hp.hpl.jena.graph.Triple t)
          Tell the event manager that the triple t has been added to the graph.
 void notifyDelete(com.hp.hpl.jena.graph.Triple t)
          Tell the event manager that the triple t has been deleted from the graph.
 void performAdd(com.hp.hpl.jena.graph.Triple t)
          Add a triple to the triple store.
 void performDelete(com.hp.hpl.jena.graph.Triple t)
          Remove a triple from the triple store.
 com.hp.hpl.jena.graph.query.QueryHandler queryHandler()
          Answer a QueryHandler bound to this graph.
protected  boolean reifierContains(com.hp.hpl.jena.graph.Triple t)
          Answer true if the reifier contains a quad matching t.
protected  int reifierSize()
          Answer the number of visible reification quads.
protected  com.hp.hpl.jena.util.iterator.ExtendedIterator reifierTriples(com.hp.hpl.jena.graph.TripleMatch m)
          Answer an iterator over all the triples exposed in this graph's reifier that match m.
 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, com.hp.hpl.jena.graph.Graph that)
          Answer a human-consumable representation of that.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

style

protected final com.hp.hpl.jena.shared.ReificationStyle style
The reification style of this graph, used when the reifier is created (and nowhere else, as it happens, which is good).


closed

protected boolean closed
Whether or not this graph has been closed - used to report ClosedExceptions when an operation is attempted on a closed graph.


queryHandler

protected com.hp.hpl.jena.graph.query.QueryHandler queryHandler
The query handler for this graph, or null if queryHandler() has not been called yet.


gem

protected com.hp.hpl.jena.graph.GraphEventManager gem
The event manager that this Graph uses to, well, manage events; allocated on demand.


bulkHandler

protected com.hp.hpl.jena.graph.BulkUpdateHandler bulkHandler
The allocated BulkUpdateHandler, or null if no handler has been allocated yet.


capabilities

protected com.hp.hpl.jena.graph.Capabilities capabilities
The allocated Capabilities object, or null if unallocated.


pm

protected com.hp.hpl.jena.shared.PrefixMapping pm

reifier

protected com.hp.hpl.jena.graph.Reifier reifier
The cache variable for the allocated Reifier.

Constructor Detail

GraphBase

public GraphBase()
Initialise this graph as one with reification style Minimal.


GraphBase

public GraphBase(com.hp.hpl.jena.shared.ReificationStyle style)
Initialise this graph with the given reification style (which will be supplied to the reifier when it is created).

Method Detail

checkOpen

protected void checkOpen()
Utility method: throw a ClosedException if this graph has been closed.


close

public void close()
Close this graph. Subgraphs may extend to discard resources.

Specified by:
close in interface com.hp.hpl.jena.graph.Graph

dependsOn

public boolean dependsOn(com.hp.hpl.jena.graph.Graph other)
Default implemenentation answers true iff this graph is the same graph as the argument graph.

Specified by:
dependsOn in interface com.hp.hpl.jena.graph.Graph

queryHandler

public com.hp.hpl.jena.graph.query.QueryHandler queryHandler()
Answer a QueryHandler bound to this graph. The default implementation returns the same SimpleQueryHandler each time ti is called; sub-classes may override if they need specialed query handlers.

Specified by:
queryHandler in interface com.hp.hpl.jena.graph.Graph

getEventManager

public com.hp.hpl.jena.graph.GraphEventManager getEventManager()
Answer the event manager for this graph; allocate a new one if required. Subclasses may override if they have a more specialed event handler. The default is a SimpleEventManager.

Specified by:
getEventManager in interface com.hp.hpl.jena.graph.Graph

notifyAdd

public void notifyAdd(com.hp.hpl.jena.graph.Triple t)
Tell the event manager that the triple t has been added to the graph.


notifyDelete

public void notifyDelete(com.hp.hpl.jena.graph.Triple t)
Tell the event manager that the triple t has been deleted from the graph.


getTransactionHandler

public com.hp.hpl.jena.graph.TransactionHandler getTransactionHandler()
Answer a transaction handler bound to this graph. The default is SimpleTransactionHandler, which handles no transactions.

Specified by:
getTransactionHandler in interface com.hp.hpl.jena.graph.Graph

getBulkUpdateHandler

public com.hp.hpl.jena.graph.BulkUpdateHandler getBulkUpdateHandler()
Answer a BulkUpdateHandler bound to this graph. The default is a SimpleBulkUpdateHandler, which does bulk update by repeated simple (add/delete) updates; the same handler is returned on each call. Subclasses may override if they have specialised implementations.

Specified by:
getBulkUpdateHandler in interface com.hp.hpl.jena.graph.Graph

getCapabilities

public com.hp.hpl.jena.graph.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 interface com.hp.hpl.jena.graph.Graph

getPrefixMapping

public com.hp.hpl.jena.shared.PrefixMapping getPrefixMapping()
Answer the PrefixMapping object for this graph, the same one each time. Subclasses are unlikely to want to modify this.

Specified by:
getPrefixMapping in interface com.hp.hpl.jena.graph.Graph

add

public void add(com.hp.hpl.jena.graph.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.

Specified by:
add in interface com.hp.hpl.jena.graph.GraphAdd

performAdd

public void performAdd(com.hp.hpl.jena.graph.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 interface GraphWithPerform

delete

public final void delete(com.hp.hpl.jena.graph.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.

Specified by:
delete in interface com.hp.hpl.jena.graph.Graph

performDelete

public void performDelete(com.hp.hpl.jena.graph.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 interface GraphWithPerform

find

public final com.hp.hpl.jena.util.iterator.ExtendedIterator find(com.hp.hpl.jena.graph.TripleMatch m)
Answer an (extended) iterator over all the triples in this Graph matching m. Subclasses cannot over-ride this, because it implements the appending of reification quadlets; instead they must implement graphBaseFind(TripleMatch).

Specified by:
find in interface com.hp.hpl.jena.graph.Graph

graphBaseFind

protected abstract com.hp.hpl.jena.util.iterator.ExtendedIterator graphBaseFind(com.hp.hpl.jena.graph.TripleMatch m)
Answer an iterator over all the triples held in this graph's non-reified triple store that match m. Subclasses must override; it is the core implementation for find(TripleMatch).


find

public final com.hp.hpl.jena.util.iterator.ExtendedIterator find(com.hp.hpl.jena.graph.Node s,
                                                                 com.hp.hpl.jena.graph.Node p,
                                                                 com.hp.hpl.jena.graph.Node o)
Description copied from interface: com.hp.hpl.jena.graph.Graph
Returns an iterator over Triple.

Specified by:
find in interface com.hp.hpl.jena.graph.Graph

graphBaseFind

protected com.hp.hpl.jena.util.iterator.ExtendedIterator graphBaseFind(com.hp.hpl.jena.graph.Node s,
                                                                       com.hp.hpl.jena.graph.Node p,
                                                                       com.hp.hpl.jena.graph.Node o)

contains

public final boolean contains(com.hp.hpl.jena.graph.Triple t)
Answer true iff t is in the graph as revealed by find(t) being non-empty. t may contain ANY wildcards. Sub-classes may over-ride reifierContains and graphBaseContains for efficiency.

Specified by:
contains in interface com.hp.hpl.jena.graph.Graph

reifierContains

protected boolean reifierContains(com.hp.hpl.jena.graph.Triple t)
Answer true if the reifier contains a quad matching t. The default implementation uses the reifier's findExposed method. Subclasses probably don't need to override (if they're interested, they probably have specialised reifiers).


graphBaseContains

protected boolean graphBaseContains(com.hp.hpl.jena.graph.Triple t)
Answer true if the graph contains any triple matching t. The default implementation uses find and checks to see if the iterator is non-empty.


contains

public final boolean contains(com.hp.hpl.jena.graph.Node s,
                              com.hp.hpl.jena.graph.Node p,
                              com.hp.hpl.jena.graph.Node o)
Answer true if this graph contains (s, p, o); this canonical implementation cannot be over-ridden.

Specified by:
contains in interface com.hp.hpl.jena.graph.Graph

containsByFind

protected final boolean containsByFind(com.hp.hpl.jena.graph.Triple t)
Utility method: answer true iff we can find at least one instantiation of the triple in this graph using find(TripleMatch).


reifierTriples

protected com.hp.hpl.jena.util.iterator.ExtendedIterator reifierTriples(com.hp.hpl.jena.graph.TripleMatch m)
Answer an iterator over all the triples exposed in this graph's reifier that match m. The default implementation delegates this to the reifier; subclasses probably don't need to override this.


getReifier

public com.hp.hpl.jena.graph.Reifier getReifier()
Answer this graph's reifier. The reifier may be lazily constructed, and it must be the same reifier on each call. The default implementation is a SimpleReifier.

Specified by:
getReifier in interface com.hp.hpl.jena.graph.Graph

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).

Specified by:
size in interface com.hp.hpl.jena.graph.Graph

reifierSize

protected int reifierSize()
Answer the number of visible reification quads. Subclasses will not normally need to override this, since it just invokes the reifier's size() method, and they can implement their own reifier.


graphBaseSize

protected int graphBaseSize()
Answer the number of triples in this graph. Default implementation counts its way through the results of a findAll. Subclasses must override if they want size() to be efficient.


isEmpty

public boolean isEmpty()
Answer true iff this graph contains no triples (hidden reification quads do not count). The default implementation is size() == 0, which is fine if size is reasonable efficient. Subclasses may override if necessary. This method may become final and defined in terms of other methods.

Specified by:
isEmpty in interface com.hp.hpl.jena.graph.Graph

isIsomorphicWith

public boolean isIsomorphicWith(com.hp.hpl.jena.graph.Graph g)
Answer true iff this graph is isomorphic to g according to the algorithm (indeed, method) in GraphMatcher.

Specified by:
isIsomorphicWith in interface com.hp.hpl.jena.graph.Graph

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.


toString

public static java.lang.String toString(java.lang.String prefix,
                                        com.hp.hpl.jena.graph.Graph that)
Answer a human-consumable representation of that. The string prefix will appear near the beginning of the string. Nodes may be prefix-compressed using that's prefix-mapping. This default implementation will display all the triples exposed by the graph (ie including reification triples if it is Standard).