org.openrdf.sesame.sailimpl.memory
Class RdfSource

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

public class RdfSource
extends Object
implements RdfSource, ValueFactory

An implementation of the RdfSource interface from the RDF Sail API that stores its data in main memory and that can use a file for persistent storage.

Caveat: Namespace prefix assignment is not guaranteed to be correct.

Author:
Arjohn Kampman

Field Summary
static String COMPRESS_FILE_KEY
          Key used to specify whether any data that is written to the file should be compressed.
static String DATA_FORMAT_KEY
          Key used to specify the format of the data in the file.
static String FILE_KEY
          Key used to specify a file for persistent storage.
 
Constructor Summary
RdfSource()
          Creates a new RdfSource.
 
Method Summary
 BNode createBNode()
          Creates a new bNode.
 BNode createBNode(String nodeId)
          creates a new bNode with the given node identifier.
 Literal createLiteral(String value)
          Creates a new literal with the supplied value.
 Literal createLiteral(String value, String language)
          Creates a new literal with the supplied value and language attribute.
 Literal createLiteral(String value, URI datatype)
          Creates a new literal with the supplied value and datatype.
 Statement createStatement(Resource subject, URI predicate, Value object)
          Creates a new statement with the supplied subject, predicate and object.
 URI createURI(String uri)
          Creates a new URI from the supplied string-representation.
 URI createURI(String namespace, String localName)
          Creates a new URI that will get the supplied namespace and local name.
 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()
          Initializes this repository.
 void initialize(File file, RDFFormat dataFormat, boolean compressFile)
          Initializes this repository, using the specified file for persistent storage.
 void initialize(Map configParams)
          Initializes this RdfSource.
 Query optimizeQuery(Query qc)
          Gives the RdfSource the oportunity to optimize a Query to its specific storage model.
 void shutDown()
          Allow the SAIL to synchronize any stale data.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_KEY

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

See Also:
Constant Field Values

DATA_FORMAT_KEY

public static final String DATA_FORMAT_KEY
Key used to specify the format of the data in the file.

See Also:
Constant Field Values

COMPRESS_FILE_KEY

public static final String COMPRESS_FILE_KEY
Key used to specify whether any data that is written to the file should be compressed.

See Also:
Constant Field Values
Constructor Detail

RdfSource

public RdfSource()
Creates a new RdfSource.

Method Detail

initialize

public void initialize(Map configParams)
                throws SailInitializationException
Initializes this RdfSource. The supplied Map can contain the following parameters:
key value
file The fully qualified name of the file that should be used for persistent data storage, e.g. c:\rdfdata\data.rdf.
dataFormat The format of the data in the file. Legal values are "rdfxml", "ntriples" and "turtle". These are the values that are returned by the constants of class RDFFormat.
compressFile Flag indicating whether the data that is written to the file (if any) should be compressed. Compressions can seriously reduce the size of the often verbose RDF data file. Compression is enabled when this parameter has the value "yes".
syncDelay 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, improving performance.

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:
RDFFormat

initialize

public void initialize()
                throws SailInitializationException
Initializes this repository. The contents of the repository will be volatile as no file will be used for persistent storage.

Throws:
SailInitializationException

initialize

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

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:
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

createURI

public URI createURI(String uri)
Description copied from interface: ValueFactory
Creates a new URI from the supplied string-representation.

Specified by:
createURI in interface ValueFactory
Parameters:
uri - A string-representation of a URI.
Returns:
An object representing the URI.

createURI

public URI createURI(String namespace,
                     String localName)
Description copied from interface: ValueFactory
Creates a new URI that will get the supplied namespace and local name.

Specified by:
createURI in interface ValueFactory
Parameters:
namespace - A namespace.
localName - A legal local name. A legal local name adheres to the definition of an NCName as specified at http://www.w3.org/TR/REC-xml-names/#NT-NCName.

createBNode

public BNode createBNode()
Description copied from interface: ValueFactory
Creates a new bNode.

Specified by:
createBNode in interface ValueFactory
Returns:
An object representing the bNode.

createBNode

public BNode createBNode(String nodeId)
Description copied from interface: ValueFactory
creates a new bNode with the given node identifier.

Specified by:
createBNode in interface ValueFactory
Parameters:
nodeId - the bnode identifier
Returns:
an object representing the bnode.

createLiteral

public Literal createLiteral(String value)
Description copied from interface: ValueFactory
Creates a new literal with the supplied value.

Specified by:
createLiteral in interface ValueFactory
Parameters:
value - The literal's value.

createLiteral

public Literal createLiteral(String value,
                             String language)
Description copied from interface: ValueFactory
Creates a new literal with the supplied value and language attribute.

Specified by:
createLiteral in interface ValueFactory
Parameters:
value - The literal's value.
language - The literal's language attribute, or null if the literal doesn't have a language.

createLiteral

public Literal createLiteral(String value,
                             URI datatype)
Description copied from interface: ValueFactory
Creates a new literal with the supplied value and datatype.

Specified by:
createLiteral in interface ValueFactory
Parameters:
value - The literal's value.
datatype - The literal's datatype, or null if the literal doesn't have a datatype.

createStatement

public Statement createStatement(Resource subject,
                                 URI predicate,
                                 Value object)
Description copied from interface: ValueFactory
Creates a new statement with the supplied subject, predicate and object.

Specified by:
createStatement in interface ValueFactory
Parameters:
subject - The statement's subject.
predicate - The statement's predicate.
object - The statement's object.
Returns:
The created statement.


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