org.openrdf.sesame.sailimpl.memory
Class RdfRepository

java.lang.Object
  extended byorg.openrdf.sesame.sailimpl.memory.RdfSource
      extended byorg.openrdf.sesame.sailimpl.memory.RdfRepository
All Implemented Interfaces:
RdfRepository, RdfSource, Sail, ValueFactory
Direct Known Subclasses:
RdfSchemaRepository

public class RdfRepository
extends RdfSource
implements RdfRepository

An implementation of the RdfRepository interface extending the class org.openrdf.sesame.sail.memory.RdfSource with write-methods.

Version:
$Revision: 1.22.2.2 $
Author:
Arjohn Kampman

Field Summary
static String SYNC_DELAY_KEY
          Key used to specify a file for persistent storage.
 
Fields inherited from class org.openrdf.sesame.sailimpl.memory.RdfSource
COMPRESS_FILE_KEY, DATA_FORMAT_KEY, FILE_KEY
 
Constructor Summary
RdfRepository()
          Creates a new RdfRepository.
 
Method Summary
 void addListener(SailChangedListener listener)
           
 void addStatement(Resource subj, URI pred, Value obj)
          Adds a statament to the repository.
 void changeNamespacePrefix(String namespace, String prefix)
          Changes the prefix of a namespace.
 void clearRepository()
          Clears the repository.
 void commitTransaction()
          Commits a started transaction.
 long getSyncDelay()
          Gets the currently configured sync delay.
 void initialize(File file, RDFFormat dataFormat, boolean compressFile)
          Initializes this repository, using the specified file for persistent storage.
 void initialize(Map configParams)
          Initializes the Sail using a set of configuration parameters.
 void removeListener(SailChangedListener listener)
           
 int removeStatements(Resource subj, URI pred, Value obj)
          Removes data statements that match the (subject, predicate, object) pattern from the repository.
 void setSyncDelay(long syncDelay)
          Sets the time (in milliseconds) to wait after a transaction was commited before writing the changed data to file.
 void shutDown()
          Allow the SAIL to synchronize any stale data.
 void startTransaction()
          Starts a transaction.
 void sync()
          Synchronizes the contents of this repository with the data that is stored on disk.
 boolean transactionStarted()
          Checks whether a transaction has been started.
 
Methods inherited from class org.openrdf.sesame.sailimpl.memory.RdfSource
createBNode, createBNode, createLiteral, createLiteral, createLiteral, createStatement, createURI, createURI, getNamespaces, getStatements, getValueFactory, hasStatement, initialize, optimizeQuery
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openrdf.sesame.sail.RdfSource
getNamespaces, getStatements, getValueFactory, hasStatement, optimizeQuery
 

Field Detail

SYNC_DELAY_KEY

public static final String SYNC_DELAY_KEY
Key used to specify a file for persistent storage.

See Also:
Constant Field Values
Constructor Detail

RdfRepository

public RdfRepository()
Creates a new RdfRepository.

Method Detail

initialize

public void initialize(Map configParams)
                throws SailInitializationException
Description copied from interface: Sail
Initializes the Sail using a set of configuration parameters. The relevant names and values of the parameters are determined by the implementation of the interface.

Specified by:
initialize in interface Sail
Overrides:
initialize in class RdfSource
Parameters:
configParams - The configuration parameters.
Throws:
SailInitializationException - If this RdfRepository could not be initialized using the supplied parameters.
See Also:
RDFFormat

initialize

public void initialize(File file,
                       RDFFormat dataFormat,
                       boolean compressFile)
                throws SailInitializationException
Description copied from class: RdfSource
Initializes this repository, using the specified file for persistent storage.

Overrides:
initialize in class RdfSource
Parameters:
file - The file to use for persistent storage.
dataFormat - The format of the data in the file. Legal values are RDFFormat.RDFXML, RDFFormat.NTRIPLES and RDFFormat.TURTLE.
compressFile - Flag indicating whether the data in the file is/should be compressed.
Throws:
SailInitializationException

shutDown

public void shutDown()
Description copied from interface: Sail
Allow the SAIL to synchronize any stale data. The SAIL can assume that shutDown() is called before an application is stopped.

Specified by:
shutDown in interface Sail
Overrides:
shutDown in class RdfSource

startTransaction

public void startTransaction()
Description copied from interface: RdfRepository
Starts a transaction. A transaction needs to be started before data can be added to or removed from the repository.

Specified by:
startTransaction in interface RdfRepository

commitTransaction

public void commitTransaction()
Description copied from interface: RdfRepository
Commits a started transaction. A transaction needs to be commited to be guaranteed that data has been added to, or removed from the repository.

Specified by:
commitTransaction in interface RdfRepository

transactionStarted

public boolean transactionStarted()
Description copied from interface: RdfRepository
Checks whether a transaction has been started.

Specified by:
transactionStarted in interface RdfRepository
Returns:
true if a transaction has been started, false otherwise.

addStatement

public void addStatement(Resource subj,
                         URI pred,
                         Value obj)
                  throws SailUpdateException
Description copied from interface: RdfRepository
Adds a statament to the repository. You must start a transaction before this method can be used.

Specified by:
addStatement in interface RdfRepository
Parameters:
subj - subject of statement
pred - predicate of statement
obj - object of statement
Throws:
SailUpdateException - If the statement could not be added.
See Also:
RdfRepository.startTransaction()

removeStatements

public int removeStatements(Resource subj,
                            URI pred,
                            Value obj)
                     throws SailUpdateException
Description copied from interface: RdfRepository
Removes data statements that match the (subject, predicate, object) pattern from the repository. All three parameters may be null to indicate wildcards. You must start a transaction before this method can be used.

Specified by:
removeStatements in interface RdfRepository
Parameters:
subj - subject of statement
pred - predicate of statement
obj - object of statement
Returns:
the number of statements that have been removed.
Throws:
SailUpdateException - If the statement(s) could not be removed.
See Also:
RdfRepository.startTransaction()

clearRepository

public void clearRepository()
                     throws SailUpdateException
Description copied from interface: RdfRepository
Clears the repository. After the repository was cleared, it will be in the same state as after initialization. You must start a transaction before this method can be used.

Specified by:
clearRepository in interface RdfRepository
Throws:
SailUpdateException - If the repository could not be cleared (for example when a transaction was not started first).

changeNamespacePrefix

public void changeNamespacePrefix(String namespace,
                                  String prefix)
                           throws SailUpdateException
Description copied from interface: RdfRepository
Changes the prefix of a namespace. The new prefix must be unique in the repository; it is not allowed to be associated with any other namespace. You must start a transaction before this method can be used.

Specified by:
changeNamespacePrefix in interface RdfRepository
Parameters:
namespace - The namespace for which the associated prefix should be changed.
prefix - The new prefix.
Throws:
SailUpdateException - If the namespace prefix could not be changed, for example when no transaction was started.

setSyncDelay

public void setSyncDelay(long syncDelay)
Sets the time (in milliseconds) to wait after a transaction was commited before writing the changed data to file. Setting this variable to 0 will force a file sync immediately after each commit. A negative value will deactivate file synchronization until the Sail is shut down. A positive value will postpone the synchronization for at least that amount of milliseconds. If in the meantime a new transaction is started, the file synchronization will be rescheduled to wait for another syncDelay ms. This way, bursts of transaction events can be combined in one file sync.

The default value for this parameter is 0 (immediate synchronization).

Parameters:
syncDelay - The sync delay in milliseconds.

getSyncDelay

public long getSyncDelay()
Gets the currently configured sync delay.

Returns:
syncDelay The sync delay in milliseconds.
See Also:
setSyncDelay(long)

sync

public void sync()
Synchronizes the contents of this repository with the data that is stored on disk. Data will only be written when the contents of the repository and data in the file are out of sync.


addListener

public void addListener(SailChangedListener listener)
Specified by:
addListener in interface RdfRepository

removeListener

public void removeListener(SailChangedListener listener)
Specified by:
removeListener in interface RdfRepository


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