org.openrdf.sesame.sailimpl.nativerdf
Class NativeRdfRepository

java.lang.Object
  extended byorg.openrdf.sesame.sailimpl.nativerdf.NativeRdfRepository
All Implemented Interfaces:
RdfRepository, RdfSource, Sail

public class NativeRdfRepository
extends Object
implements RdfRepository

An implementation of the RdfRepository interface from the RDF Sail API that stores its data in, and queries it from files on disk.

Author:
Arjohn Kampman

Field Summary
static String DATA_DIR_KEY
          Key used to specify a data directory in the initialization parameters.
static String TRIPLES_INDEXES_KEY
          Key used to specify which triple indexes to use.
 
Constructor Summary
NativeRdfRepository()
          Creates a new NativeRdfRepository.
 
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.
 NamespaceIterator getNamespaces()
          Gets the prefix and name of all namespaces.
 StatementIterator getStatements(Resource subj, URI pred, Value obj)
          Gets all statements with a specific subject, predicate and/or object.
 ValueFactory getValueFactory()
          Gets a ValueFactory object that can be used to create URI-, blank node- and literal objects.
 boolean hasStatement(Resource subj, URI pred, Value obj)
          Checks whether some statement with a specific subject, predicate and/or object is present in the repository.
 void initialize(File dataDir)
          Initializes this repository.
 void initialize(File dataDir, String tripleIndexes)
          Initializes this repository.
 void initialize(Map configParams)
          Initializes this NativeRdfRepository.
static void main(String[] args)
           
 Query optimizeQuery(Query qc)
          Gives the RdfSource the oportunity to optimize a Query to its specific storage model.
 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 shutDown()
          Allow the SAIL to synchronize any stale data.
 void startTransaction()
          Starts a transaction.
 boolean transactionStarted()
          Checks whether a transaction has been started.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATA_DIR_KEY

public static final String DATA_DIR_KEY
Key used to specify a data directory in the initialization parameters.

See Also:
Constant Field Values

TRIPLES_INDEXES_KEY

public static final String TRIPLES_INDEXES_KEY
Key used to specify which triple indexes to use.

See Also:
Constant Field Values
Constructor Detail

NativeRdfRepository

public NativeRdfRepository()
Creates a new NativeRdfRepository.

Method Detail

initialize

public void initialize(Map configParams)
                throws SailInitializationException
Initializes this NativeRdfRepository. The supplied Map can contain the following parameters:
keyvalue
dirThe fully qualified name of the data directory

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

initialize

public void initialize(File dataDir)
                throws SailInitializationException
Initializes this repository.

Parameters:
dataDir - The data directory.
Throws:
SailInternalException - If the initialization failed.
SailInitializationException

initialize

public void initialize(File dataDir,
                       String tripleIndexes)
                throws SailInitializationException
Initializes this repository.

Parameters:
dataDir - The data directory.
Throws:
SailInternalException - If the initialization failed.
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

getValueFactory

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

Specified by:
getValueFactory in interface RdfSource
Returns:
a ValueFactory object for this RdfSource instance.

getStatements

public StatementIterator getStatements(Resource subj,
                                       URI pred,
                                       Value obj)
Description copied from interface: RdfSource
Gets all statements with a specific subject, predicate and/or object. All three parameters may be null to indicate wildcards.

Specified by:
getStatements in interface RdfSource
Parameters:
subj - subject of pattern
pred - predicate of pattern
obj - object of pattern
Returns:
iterator over statements

hasStatement

public boolean hasStatement(Resource subj,
                            URI pred,
                            Value obj)
Description copied from interface: RdfSource
Checks whether some statement with a specific subject, predicate and/or object is present in the repository. All three parameters may be null to indicate wildcards.

Specified by:
hasStatement in interface RdfSource
Parameters:
subj - subject of statement
pred - predicate of statement
obj - object of statement
Returns:
boolean indicating if specified statement is present

optimizeQuery

public Query optimizeQuery(Query qc)
Description copied from interface: RdfSource
Gives the RdfSource the oportunity to optimize a Query to its specific storage model.

Specified by:
optimizeQuery in interface RdfSource
Parameters:
qc - The Query to optimize.
Returns:
The optimized query.

getNamespaces

public NamespaceIterator getNamespaces()
Description copied from interface: RdfSource
Gets the prefix and name of all namespaces.

Specified by:
getNamespaces in interface RdfSource
Returns:
iterator over namespaces

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

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception

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.