org.openrdf.model.impl
Class GraphImpl

java.lang.Object
  extended byorg.openrdf.model.impl.GraphImpl
All Implemented Interfaces:
Graph

public class GraphImpl
extends Object
implements Graph

GraphImpl - an implementation of the graph interface that uses a local repository as storage backend. GraphImpl is not thread-safe.

Author:
Jeen Broekstra, Arjohn Kampman

Constructor Summary
GraphImpl()
          Creates a new GraphImpl.
GraphImpl(LocalRepository repository)
          Creates a new GraphImpl that uses the supplied LocalRepository as storage backend.
GraphImpl(RdfRepository sail)
          Deprecated. low-level SAIL api should not be exposed in access APIs; use constructor with LocalRepository object instead.
 
Method Summary
 void add(Collection statements)
          Adds all statements in the Collection to the graph.
 void add(Collection statements, boolean joinBlankNodes)
          Adds all statements in the Collection to the graph.
 void add(Graph graph)
          Adds all statements in the supplied graph to this graph.
 void add(Graph graph, boolean joinBlankNodes)
          Adds all statements in the supplied graph to this graph.
 void add(Resource subject, URI predicate, Value object)
          Adds a single statement to the graph.
 void add(Statement st)
          Adds a single statement to the graph.
 void add(StatementIterator iterator)
          Adds all statements in the iterator to the graph.
 void add(StatementIterator iterator, boolean joinBlankNodes)
          Adds all statements in the iterator to the graph.
 void clear()
          Clears the graph.
 boolean contains(Resource subject, URI predicate, Value object)
          Checks if a statement matching the (subject, predicate, object) pattern is present in the graph.
 boolean contains(Statement st)
          Checks if the supplied statement is present in the graph.
 Collection getStatementCollection(Resource subject, URI predicate, Value object)
          Retrieves all statements matching the (subject, predicate, object) pattern in the graph as a Collection.
 StatementIterator getStatements()
          Retrieves all statements in the graph as an iterator
 StatementIterator getStatements(Resource subject, URI predicate, Value object)
          Retrieves all statements matching the (subject, predicate, object) pattern in the graph as an iterator.
 ValueFactory getValueFactory()
          Retrieves a ValueFactory for this graph.
 int remove(Graph graph)
          Remove all statements in the supplied graph from this graph.
 int remove(Resource subject, URI predicate, Value object)
          Remove all statements matching the (subject, predicate, object) pattern from the graph.
 int remove(Statement st)
          Remove the supplied statement from the graph.
 int remove(StatementIterator iterator)
          Remove all statements in the StatementIterator from the graph.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphImpl

public GraphImpl()
Creates a new GraphImpl. The GraphImpl uses an in-memory RdfRepository as storage backend.


GraphImpl

public GraphImpl(LocalRepository repository)
Creates a new GraphImpl that uses the supplied LocalRepository as storage backend.

Parameters:
repository - The LocalRepository to be used as backend.

GraphImpl

public GraphImpl(RdfRepository sail)
Deprecated. low-level SAIL api should not be exposed in access APIs; use constructor with LocalRepository object instead.

Creates a new GraphImpl that uses the supplied Sail as storage backend. The constructor assumes the supplied Sail is initialized.

Parameters:
sail - the Sail object to be used as storage backend
Method Detail

add

public void add(Resource subject,
                URI predicate,
                Value object)
Description copied from interface: Graph
Adds a single statement to the graph. If the supplied parameters contain any blank nodes that are shared with this graph, these will be joined.

Specified by:
add in interface Graph
Parameters:
subject - the statement subject
predicate - the statement predicate
object - the statement object

add

public void add(Statement st)
Description copied from interface: Graph
Adds a single statement to the graph. If the supplied statements contains any blank nodes that are shared with this graph, these will be joined.

Specified by:
add in interface Graph
Parameters:
st - the statement to be added

add

public void add(StatementIterator iterator)
Description copied from interface: Graph
Adds all statements in the iterator to the graph. If the supplied iterator contains any blank nodes that are shared with this graph, these will be joined.

Specified by:
add in interface Graph
Parameters:
iterator - an iterator containing statements

add

public void add(StatementIterator iterator,
                boolean joinBlankNodes)
Description copied from interface: Graph
Adds all statements in the iterator to the graph.

Specified by:
add in interface Graph
Parameters:
iterator - an iterator containing statements
joinBlankNodes - specifies whether blank nodes in the supplied iterator should be joined with this graph. If false, new blank nodes will be created for each blank node in the supplied iterator.

add

public void add(Collection statements)
Description copied from interface: Graph
Adds all statements in the Collection to the graph. If the supplied collection contains any blank nodes that are shared with this graph, these will be joined.

Specified by:
add in interface Graph
Parameters:
statements - a Collection containing Statement objects.

add

public void add(Collection statements,
                boolean joinBlankNodes)
Description copied from interface: Graph
Adds all statements in the Collection to the graph.

Specified by:
add in interface Graph
Parameters:
statements - a Collection containing statements
joinBlankNodes - specifies whether blank nodes in the supplied Collection should be joined with this graph. If false, new blank nodes will be created for each blank node in the supplied Collection.

add

public void add(Graph graph)
Description copied from interface: Graph
Adds all statements in the supplied graph to this graph. If the supplied graph contains any blank nodes that are shared with this graph, these will be joined.

Specified by:
add in interface Graph
Parameters:
graph - the supplied graph, to be added to this graph.

add

public void add(Graph graph,
                boolean joinBlankNodes)
Description copied from interface: Graph
Adds all statements in the supplied graph to this graph.

Specified by:
add in interface Graph
Parameters:
graph - the supplied graph, to be added to this graph.
joinBlankNodes - specifies whether blank nodes in the supplied graph should be joined with this graph. If false, new blank nodes will be created for each blank node in the supplied graph.

contains

public boolean contains(Resource subject,
                        URI predicate,
                        Value object)
Description copied from interface: Graph
Checks if a statement matching the (subject, predicate, object) pattern is present in the graph.

Specified by:
contains in interface Graph
Parameters:
subject - the statement subject, or null for a wildcard.
predicate - the statement predicate, or null for a wildcard.
object - the statement object, or null for a wildcard.
Returns:
true if a matching statement is found, false otherwise.

contains

public boolean contains(Statement st)
Description copied from interface: Graph
Checks if the supplied statement is present in the graph.

Specified by:
contains in interface Graph
Parameters:
st - the statement for which presence is checked.
Returns:
true if the statement is present in the graph, false otherwise.

getStatements

public StatementIterator getStatements()
Description copied from interface: Graph
Retrieves all statements in the graph as an iterator

Specified by:
getStatements in interface Graph
Returns:
a StatementIterator containing all statements in the graph.

getStatements

public StatementIterator getStatements(Resource subject,
                                       URI predicate,
                                       Value object)
Description copied from interface: Graph
Retrieves all statements matching the (subject, predicate, object) pattern in the graph as an iterator.

Specified by:
getStatements in interface Graph
Parameters:
subject - the statement subject, or null for a wildcard
predicate - the statement predicate, or null for a wildcard
object - the statement object, or null for a wildcard
Returns:
a StatementIterator containing all matching statements in the graph.

remove

public int remove(Resource subject,
                  URI predicate,
                  Value object)
Description copied from interface: Graph
Remove all statements matching the (subject, predicate, object) pattern from the graph.

Specified by:
remove in interface Graph
Parameters:
subject - the statement subject, or null for a wildcard.
predicate - the statement predicate, or null for a wildcard.
object - the statement object, or null for a wildcard.
Returns:
the number of statements that were removed.

remove

public int remove(Statement st)
Description copied from interface: Graph
Remove the supplied statement from the graph.

Specified by:
remove in interface Graph
Parameters:
st - the statement to be removed.
Returns:
the number of statements removed. If the statement was not present in the graph, 0 is returned.

remove

public int remove(StatementIterator iterator)
Description copied from interface: Graph
Remove all statements in the StatementIterator from the graph.

Specified by:
remove in interface Graph
Parameters:
iterator - A StatementIterator containing all statements to be removed.
Returns:
the number of statements removed.

clear

public void clear()
Description copied from interface: Graph
Clears the graph. All statements are removed from the graph.

Specified by:
clear in interface Graph

getStatementCollection

public Collection getStatementCollection(Resource subject,
                                         URI predicate,
                                         Value object)
Description copied from interface: Graph
Retrieves all statements matching the (subject, predicate, object) pattern in the graph as a Collection.

Specified by:
getStatementCollection in interface Graph
Parameters:
subject - the statement subject, or null for a wildcard.
predicate - the statement predicate, or null for a wildcard.
object - the statement object, or null for a wildcard.
Returns:
a Collection of matching statements.

remove

public int remove(Graph graph)
Description copied from interface: Graph
Remove all statements in the supplied graph from this graph.

Specified by:
remove in interface Graph
Parameters:
graph -
Returns:
the number of statements removed.

getValueFactory

public ValueFactory getValueFactory()
Description copied from interface: Graph
Retrieves a ValueFactory for this graph.

Specified by:
getValueFactory in interface Graph
Returns:
a ValueFactory.


Copyright © 2002-2006 Aduna BV, GNU LGPL License applies.