org.openrdf.sail.helpers
Class SailConnectionWrapper

java.lang.Object
  extended by org.openrdf.sail.helpers.SailConnectionWrapper
All Implemented Interfaces:
SailConnection
Direct Known Subclasses:
AutoCommitSailConnection, DatasetConnection, NotifyingSailConnectionWrapper, PreconditionSailConnection, SynchronizedSailConnection, TrackingSailConnection

public class SailConnectionWrapper
extends Object
implements SailConnection

An implementation of the Transaction interface that wraps another Transaction object and forwards any method calls to the wrapped transaction.

Author:
jeen

Constructor Summary
SailConnectionWrapper(SailConnection delegate)
          Creates a new TransactionWrapper object that wraps the supplied connection.
 
Method Summary
 void addStatement(Resource subj, URI pred, Value obj, Resource... contexts)
          Adds a statement to each context in the specified contexts.
 void begin()
          Begins a transaction requiring SailConnection.commit() or SailConnection.rollback() to be called to close the transaction.
 void clearNamespaces()
          Removes all namespace declarations from the repository.
 void close()
          Closes the connection.
 void commit()
          Commits any updates that have been performed since the last time SailConnection.commit() or SailConnection.rollback() was called.
 Cursor<? extends BindingSet> evaluate(QueryModel query, BindingSet bindings, boolean includeInferred)
          Evaluates the supplied TupleExpr on the data contained in this Sail object, using the (optional) dataset and supplied bindings as input parameters.
 Cursor<? extends Resource> getContextIDs()
          Returns the set of all unique context identifiers that are used to store statements.
protected  SailConnection getDelegate()
          Gets the connection that is wrapped by this object.
 String getNamespace(String prefix)
          Gets the namespace that is mapped to the specified prefix.
 Cursor<? extends Namespace> getNamespaces()
          Gets the namespaces relevant to the data contained in this Sail object.
 Cursor<? extends Statement> getStatements(Resource subj, URI pred, Value obj, boolean includeInferred, Resource... contexts)
          Gets all statements from the specified contexts that have a specific subject, predicate and/or object.
 Isolation getTransactionIsolation()
          Retrieves this connection's current transaction isolation level.
 ValueFactory getValueFactory()
          Gets a ValueFactory object that can be used to create URI-, blank node-, literal- and statement objects.
 boolean isAutoCommit()
          Indicates if the connection is in auto-commit mode.
 boolean isOpen()
          Checks whether this SailConnection is open.
 boolean isReadOnly()
          Indicates whether this connection is in read-only mode.
 void removeNamespace(String prefix)
          Removes a namespace declaration by removing the association between a prefix and a namespace name.
 void removeStatements(Resource subj, URI pred, Value obj, Resource... contexts)
          Removes all statements matching the specified subject, predicate and object from the repository.
 void rollback()
          Rolls back the SailConnection, discarding any uncommitted changes that have been made in this SailConnection.
 void setNamespace(String prefix, String name)
          Sets the prefix of a namespace.
 void setReadOnly(boolean readOnly)
          Puts this connection in read-only mode as a hint to the driver to enable repository optimizations.
 void setTransactionIsolation(Isolation isolation)
          Attempts to change the transaction isolation level for this connection to the specified value.
 long size(Resource subj, URI pred, Value obj, boolean includeInferred, Resource... contexts)
          Returns the number of statements matching the specified pattern.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SailConnectionWrapper

public SailConnectionWrapper(SailConnection delegate)
Creates a new TransactionWrapper object that wraps the supplied connection.

Method Detail

getDelegate

protected SailConnection getDelegate()
Gets the connection that is wrapped by this object.

Returns:
The SailConnection object that was supplied to the constructor of this class.

isOpen

public boolean isOpen()
               throws StoreException
Description copied from interface: SailConnection
Checks whether this SailConnection is open. A SailConnection is open from the moment it is created until it is closed.

Specified by:
isOpen in interface SailConnection
Throws:
StoreException
See Also:
SailConnection.close()

close

public void close()
           throws StoreException
Description copied from interface: SailConnection
Closes the connection. Any updates that haven't been committed yet will be rolled back. The connection can no longer be used once it is closed.

Specified by:
close in interface SailConnection
Throws:
StoreException

getTransactionIsolation

public Isolation getTransactionIsolation()
                                  throws StoreException
Description copied from interface: SailConnection
Retrieves this connection's current transaction isolation level.

Specified by:
getTransactionIsolation in interface SailConnection
Returns:
The current transaction isolation level.
Throws:
StoreException - If an access error occurs or this method is called on a closed connection
See Also:
SailConnection.setTransactionIsolation(org.openrdf.store.Isolation)

setTransactionIsolation

public void setTransactionIsolation(Isolation isolation)
                             throws StoreException
Description copied from interface: SailConnection
Attempts to change the transaction isolation level for this connection to the specified value.

Note: If this method is called during a transaction, the result is implementation-defined.

Specified by:
setTransactionIsolation in interface SailConnection
Parameters:
isolation - Any Isolation except for NONE, since that indicates that transactions are not supported.
Throws:
StoreException - If an access error occurs, this method is called on a closed connection
See Also:
SailConnection.getTransactionIsolation()

isReadOnly

public boolean isReadOnly()
                   throws StoreException
Description copied from interface: SailConnection
Indicates whether this connection is in read-only mode.

Specified by:
isReadOnly in interface SailConnection
Returns:
true if this Connection object is read-only; false otherwise.
Throws:
StoreException - If a repository access error occurs.

setReadOnly

public void setReadOnly(boolean readOnly)
                 throws StoreException
Description copied from interface: SailConnection
Puts this connection in read-only mode as a hint to the driver to enable repository optimizations.

Note: This method cannot be called during a transaction.

Specified by:
setReadOnly in interface SailConnection
Parameters:
readOnly - true enables read-only mode; false disables it
Throws:
StoreException - If a repository access error occurs or this method is called during a transaction.

isAutoCommit

public boolean isAutoCommit()
                     throws StoreException
Description copied from interface: SailConnection
Indicates if the connection is in auto-commit mode. The connection is not in auto-commit when SailConnection.begin() has been called but SailConnection.commit() or SailConnection.rollback() still has to be called to finish the transaction.

Specified by:
isAutoCommit in interface SailConnection
Throws:
StoreException - If a repository access error occurs.

begin

public void begin()
           throws StoreException
Description copied from interface: SailConnection
Begins a transaction requiring SailConnection.commit() or SailConnection.rollback() to be called to close the transaction.

Specified by:
begin in interface SailConnection
Throws:
StoreException - If the connection could not start a transaction, or if it already has an active transaction.
See Also:
SailConnection.isAutoCommit()

commit

public void commit()
            throws StoreException
Description copied from interface: SailConnection
Commits any updates that have been performed since the last time SailConnection.commit() or SailConnection.rollback() was called.

Specified by:
commit in interface SailConnection
Throws:
StoreException - If the SailConnection could not be committed, or if the connection does not have an active connection.

rollback

public void rollback()
              throws StoreException
Description copied from interface: SailConnection
Rolls back the SailConnection, discarding any uncommitted changes that have been made in this SailConnection.

Specified by:
rollback in interface SailConnection
Throws:
StoreException - If the SailConnection could not be rolled back, or if the connection does not have an active connection.

getValueFactory

public ValueFactory getValueFactory()
Description copied from interface: SailConnection
Gets a ValueFactory object that can be used to create URI-, blank node-, literal- and statement objects.

Specified by:
getValueFactory in interface SailConnection
Returns:
a ValueFactory object for this Sail object.

evaluate

public Cursor<? extends BindingSet> evaluate(QueryModel query,
                                             BindingSet bindings,
                                             boolean includeInferred)
                                      throws StoreException
Description copied from interface: SailConnection
Evaluates the supplied TupleExpr on the data contained in this Sail object, using the (optional) dataset and supplied bindings as input parameters.

Specified by:
evaluate in interface SailConnection
bindings - A set of input parameters for the query evaluation. The keys reference variable names that should be bound to the value they map to.
includeInferred - Indicates whether inferred triples are to be considered in the query result. If false, no inferred statements are returned; if true, inferred statements are returned if available
Returns:
The TupleQueryResult.
Throws:
StoreException - If the Sail object encountered an error or unexpected situation internally.

getContextIDs

public Cursor<? extends Resource> getContextIDs()
                                         throws StoreException
Description copied from interface: SailConnection
Returns the set of all unique context identifiers that are used to store statements.

Specified by:
getContextIDs in interface SailConnection
Returns:
An iterator over the context identifiers, should not contain any duplicates.
Throws:
StoreException

getStatements

public Cursor<? extends Statement> getStatements(Resource subj,
                                                 URI pred,
                                                 Value obj,
                                                 boolean includeInferred,
                                                 Resource... contexts)
                                          throws StoreException
Description copied from interface: SailConnection
Gets all statements from the specified contexts that have a specific subject, predicate and/or object. All three parameters may be null to indicate wildcards. The includeInferred parameter can be used to control which statements are fetched: all statements or only the statements that have been added explicitly.

Specified by:
getStatements in interface SailConnection
Parameters:
subj - A Resource specifying the subject, or null for a wildcard.
pred - A URI specifying the predicate, or null for a wildcard.
obj - A Value specifying the object, or null for a wildcard.
includeInferred - if false, no inferred statements are returned; if true, inferred statements are returned if available
contexts - The context(s) to get the data from. Note that this parameter is a vararg and as such is optional. If no contexts are supplied the method operates on the entire repository.
Returns:
The statements matching the specified pattern.
Throws:
StoreException - If the Sail object encountered an error or unexpected situation internally.

size

public long size(Resource subj,
                 URI pred,
                 Value obj,
                 boolean includeInferred,
                 Resource... contexts)
          throws StoreException
Description copied from interface: SailConnection
Returns the number of statements matching the specified pattern.

Specified by:
size in interface SailConnection
Parameters:
subj - A Resource specifying the subject, or null for a wildcard.
pred - A URI specifying the predicate, or null for a wildcard.
obj - A Value specifying the object, or null for a wildcard.
includeInferred - Indicates whether inferred statements should be counted.
contexts - The context(s) to get the data from. Note that this parameter is a vararg and as such is optional. If no contexts are supplied the method operates on the entire repository.
Returns:
The number of explicit statements in this Sail.
Throws:
StoreException

addStatement

public void addStatement(Resource subj,
                         URI pred,
                         Value obj,
                         Resource... contexts)
                  throws StoreException
Description copied from interface: SailConnection
Adds a statement to each context in the specified contexts.

Specified by:
addStatement in interface SailConnection
Parameters:
subj - The subject of the statement to add.
pred - The predicate of the statement to add.
obj - The object of the statement to add.
contexts - The context(s) to add the statement to. Note that this parameter is a vararg and as such is optional. If no contexts are supplied the method operates on the entire repository.
Throws:
StoreException - If the statement could not be added.

removeStatements

public void removeStatements(Resource subj,
                             URI pred,
                             Value obj,
                             Resource... contexts)
                      throws StoreException
Description copied from interface: SailConnection
Removes all statements matching the specified subject, predicate and object from the repository. All three parameters may be null to indicate wildcards.

Specified by:
removeStatements in interface SailConnection
Parameters:
subj - The subject of the statement that should be removed, or null to indicate a wildcard.
pred - The predicate of the statement that should be removed, or null to indicate a wildcard.
obj - The object of the statement that should be removed , or null to indicate a wildcard. *
contexts - The context(s) from which to remove the statement. Note that this parameter is a vararg and as such is optional. If no contexts are supplied the method operates on the entire repository.
Throws:
StoreException - If the statement could not be removed.

getNamespaces

public Cursor<? extends Namespace> getNamespaces()
                                          throws StoreException
Description copied from interface: SailConnection
Gets the namespaces relevant to the data contained in this Sail object.

Specified by:
getNamespaces in interface SailConnection
Returns:
An iterator over the relevant namespaces, should not contain any duplicates.
Throws:
StoreException - If the Sail object encountered an error or unexpected situation internally.

getNamespace

public String getNamespace(String prefix)
                    throws StoreException
Description copied from interface: SailConnection
Gets the namespace that is mapped to the specified prefix.

Specified by:
getNamespace in interface SailConnection
Parameters:
prefix - A namespace prefix.
Returns:
The namespace name that the specified prefix maps to.
Throws:
StoreException

setNamespace

public void setNamespace(String prefix,
                         String name)
                  throws StoreException
Description copied from interface: SailConnection
Sets the prefix of a namespace.

Specified by:
setNamespace in interface SailConnection
Parameters:
prefix - The new prefix.
name - The namespace name that the prefix maps to.
Throws:
StoreException

removeNamespace

public void removeNamespace(String prefix)
                     throws StoreException
Description copied from interface: SailConnection
Removes a namespace declaration by removing the association between a prefix and a namespace name.

Specified by:
removeNamespace in interface SailConnection
Parameters:
prefix - The namespace prefix of which the assocation with a namespace name is to be removed.
Throws:
StoreException - If the namespace prefix could not be removed.

clearNamespaces

public void clearNamespaces()
                     throws StoreException
Description copied from interface: SailConnection
Removes all namespace declarations from the repository.

Specified by:
clearNamespaces in interface SailConnection
Throws:
StoreException - If the namespaces could not be removed.


Copyright © 2001-2009 Aduna. All Rights Reserved.