org.jrdf.graph.mem
Class GraphImpl

java.lang.Object
  extended byorg.jrdf.graph.mem.GraphImpl
All Implemented Interfaces:
Graph, Serializable

public class GraphImpl
extends Object
implements Graph, Serializable

A memory based RDF Graph.

Version:
$Revision: 1.1 $
Author:
Paul Gearon, Andrew Newman
See Also:
Serialized Form

Constructor Summary
GraphImpl()
          Default constructor.
 
Method Summary
 void add(Iterator triples)
          Adds an iterator containing triples into the graph.
 void add(SubjectNode subject, PredicateNode predicate, ObjectNode object)
          Adds a triple to the graph.
 void add(Triple triple)
          Adds a triple to the graph.
 void close()
          Closes any underlying resources used by this graph.
 boolean contains(SubjectNode subject, PredicateNode predicate, ObjectNode object)
          Test the graph for the occurrence of a statement.
 boolean contains(Triple triple)
          Test the graph for the occurrence of the triple.
 ClosableIterator find(SubjectNode subject, PredicateNode predicate, ObjectNode object)
          Returns an iterator to a set of statements that match a given subject, predicate and object.
 ClosableIterator find(Triple triple)
          Returns an iterator to a set of statements that match a given subject, predicate and object.
 GraphElementFactory getElementFactory()
          Returns the node factory for the graph, or creates one.
 long getNumberOfTriples()
          Returns the number of triples in the graph.
 TripleFactory getTripleFactory()
          Returns the triple factory for the graph, or creates one.
 boolean isEmpty()
          Returns true if the graph is empty i.e. the number of triples is 0.
 void remove(Iterator triples)
          Removes an iterator containing triples from the graph.
 void remove(SubjectNode subject, PredicateNode predicate, ObjectNode object)
          Removes a triple from the graph.
 void remove(Triple triple)
          Removes a triple from the graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphImpl

public GraphImpl()
          throws GraphException
Default constructor.

Throws:
GraphException - There was an error creating the factory.
Method Detail

contains

public boolean contains(SubjectNode subject,
                        PredicateNode predicate,
                        ObjectNode object)
                 throws GraphException
Test the graph for the occurrence of a statement. A null value for any of the parts of a triple are treated as unconstrained, any values will be returned.

Specified by:
contains in interface Graph
Parameters:
subject - The subject to find or null to indicate any subject.
predicate - The predicate to find or null to indicate any predicate.
object - The object to find or null to indicate any object.
Returns:
True if the statement is found in the model, otherwise false.
Throws:
GraphException - If there was an error accessing the graph.

contains

public boolean contains(Triple triple)
                 throws GraphException
Test the graph for the occurrence of the triple. A null value for any of the parts of a triple are treated as unconstrained, any values will be returned.

Specified by:
contains in interface Graph
Parameters:
triple - The triple to find.
Returns:
True if the triple is found in the graph, otherwise false.
Throws:
GraphException - If there was an error accessing the graph.

find

public ClosableIterator find(SubjectNode subject,
                             PredicateNode predicate,
                             ObjectNode object)
                      throws GraphException
Returns an iterator to a set of statements that match a given subject, predicate and object. A null value for any of the parts of a triple are treated as unconstrained, any values will be returned.

Specified by:
find in interface Graph
Parameters:
subject - The subject to find or null to indicate any subject.
predicate - The predicate to find or null to indicate any predicate.
object - ObjectNode The object to find or null to indicate any object.
Returns:
an iterator containing the matching statements.
Throws:
GraphException - If there was an error accessing the graph.

find

public ClosableIterator find(Triple triple)
                      throws GraphException
Returns an iterator to a set of statements that match a given subject, predicate and object. A null value for any of the parts of a triple are treated as unconstrained, any values will be returned.

Specified by:
find in interface Graph
Parameters:
triple - The triple to find.
Returns:
an iterator containing the matching statements.
Throws:
GraphException - If there was an error accessing the graph.

add

public void add(SubjectNode subject,
                PredicateNode predicate,
                ObjectNode object)
         throws GraphException
Adds a triple to the graph.

Specified by:
add in interface Graph
Parameters:
subject - The subject.
predicate - The predicate.
object - The object.
Throws:
GraphException - If the statement can't be made.

add

public void add(Triple triple)
         throws GraphException
Adds a triple to the graph.

Specified by:
add in interface Graph
Parameters:
triple - The triple.
Throws:
GraphException - If the statement can't be made.

add

public void add(Iterator triples)
         throws GraphException
Adds an iterator containing triples into the graph.

Specified by:
add in interface Graph
Parameters:
triples - The triple iterator.
Throws:
GraphException - If the statements can't be made.

remove

public void remove(SubjectNode subject,
                   PredicateNode predicate,
                   ObjectNode object)
            throws GraphException
Removes a triple from the graph.

Specified by:
remove in interface Graph
Parameters:
subject - The subject.
predicate - The predicate.
object - The object.
Throws:
GraphException - If there was an error revoking the statement, for example if it didn't exist.

remove

public void remove(Triple triple)
            throws GraphException
Removes a triple from the graph.

Specified by:
remove in interface Graph
Parameters:
triple - The triple.
Throws:
GraphException - If there was an error revoking the statement, for example if it didn't exist.

remove

public void remove(Iterator triples)
            throws GraphException
Removes an iterator containing triples from the graph.

Specified by:
remove in interface Graph
Parameters:
triples - The triple iterator.
Throws:
GraphException - If the statements can't be revoked.

getElementFactory

public GraphElementFactory getElementFactory()
Returns the node factory for the graph, or creates one.

Specified by:
getElementFactory in interface Graph
Returns:
the node factory for the graph, or creates one.

getTripleFactory

public TripleFactory getTripleFactory()
Returns the triple factory for the graph, or creates one.

Specified by:
getTripleFactory in interface Graph
Returns:
the triple factory for the graph, or creates one.

getNumberOfTriples

public long getNumberOfTriples()
                        throws GraphException
Returns the number of triples in the graph.

Specified by:
getNumberOfTriples in interface Graph
Returns:
the number of triples in the graph.
Throws:
GraphException - If the statements number of statements in the graph fails to be found.

isEmpty

public boolean isEmpty()
                throws GraphException
Returns true if the graph is empty i.e. the number of triples is 0.

Specified by:
isEmpty in interface Graph
Returns:
true if the graph is empty i.e. the number of triples is 0.
Throws:
GraphException - If the statements number of statements in the graph fails to be found.

close

public void close()
Closes any underlying resources used by this graph.

Specified by:
close in interface Graph