org.openrdf.sesame.sailimpl.rdbms
Class RdfSource

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

public class RdfSource
extends Object
implements RdfSource, TableNames, ValueFactory

A portable implementation of the RdfSource interface for relational databases, based on (a subset of) the SQL2/SQL92 standard. This class defines the read-only methods, the subclass RdfRepository defines the update methods.

Version:
$Revision: 1.46.2.15 $
Author:
Arjohn Kampman, Adam Skutt

Field Summary
static String JDBC_DRIVER_KEY
          Key used to specify a JDBC driver in the initialization parameters
static String JDBC_URL_KEY
          Key used to specify a JDBC URL in the initialization parameters
static String KEY_EXPORT_FLAGS
          Key used to store the status of the export flags in the metadata table
static String KEY_SCHEMACREATOR
          Key used to store the schema creator in the metadata table
static String KEY_SCHEMAVERSION
          Key used to store the schema version in the metadata table
static String PASSWORD_KEY
          Key used to specify a password in the initialization parameters
static String USER_KEY
          Key used to specify a username in the initialization parameters
static String VALUE_DIRTY
          Value used to indiate an "dirty" status in the metadata table
static String VALUE_UP_TO_DATE
          Value used to indiate an "up-to-date" status in the metadata table
 
Fields inherited from interface org.openrdf.sesame.sailimpl.rdbms.TableNames
ADDED_TRIPLES_TABLE, ALL_INFERRED_TABLE, ALL_NEW_TRIPLES_TABLE, CLASS_TABLE, DEPEND_TABLE, DIRECT_SUBCLASSOF_TABLE, DIRECT_SUBPROPERTYOF_TABLE, DOMAIN_TABLE, EXPIRED_LITERALS_TABLE, EXPIRED_RESOURCES_TABLE, EXPIRED_TRIPLES_TABLE, EXPIRED_VALUES_TABLE, GROUNDED_TRIPLES_TABLE, INFERRED_TABLE, INSTANCEOF_TABLE, LITERALS_TABLE, NAMESPACES_TABLE, NEW_GROUNDED_TRIPLES_TABLE, NEW_TRIPLES_TABLE, PROPER_INSTANCEOF_TABLE, PROPERTY_TABLE, RANGE_TABLE, RAW_TRIPLES_TABLE, REP_INFO_TABLE, RESOURCES_TABLE, SUBCLASSOF_TABLE, SUBPROPERTYOF_TABLE, TRIPLES_TABLE
 
Constructor Summary
RdfSource()
          Creates a new RdfSource object that will be able to read triples from an RDF database.
 
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.
 IdLiteral getLiteral(int id)
          Gets the Literal for the supplied ID.
 NamespaceIterator getNamespaces()
          Gets the prefix and name of all namespaces.
 IdResource getResource(int id)
          Gets the Resource for the supplied ID.
 StatementIterator getStatements(Resource subj, URI pred, Value obj)
          Gets all statements with a specific subject, predicate and/or object.
 StatementIterator getStatements(Resource subj, URI pred, Value obj, boolean explicitOnly)
           
 IdValue getValue(int id)
          Gets the Value for the supplied ID.
 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.
 boolean hasStatement(Resource subj, URI pred, Value obj, boolean explicitOnly)
           
 void initialize(Map configParams)
          Initializes the RdfSource.
 void initialize(String jdbcDriver, String jdbcUrl)
          Initializes the RdfSource.
 void initialize(String jdbcDriver, String jdbcUrl, String user, String password)
          Initializes the RdfSource.
 Query optimizeQuery(Query query)
          Merges all TriplePatterns to one large SQL-join and includes as much of the boolean constraints as possible.
 void shutDown()
          Disconnects from the database.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_SCHEMAVERSION

public static final String KEY_SCHEMAVERSION
Key used to store the schema version in the metadata table. *

See Also:
Constant Field Values

KEY_SCHEMACREATOR

public static final String KEY_SCHEMACREATOR
Key used to store the schema creator in the metadata table. *

See Also:
Constant Field Values

KEY_EXPORT_FLAGS

public static final String KEY_EXPORT_FLAGS
Key used to store the status of the export flags in the metadata table. *

See Also:
Constant Field Values

VALUE_UP_TO_DATE

public static final String VALUE_UP_TO_DATE
Value used to indiate an "up-to-date" status in the metadata table. *

See Also:
Constant Field Values

VALUE_DIRTY

public static final String VALUE_DIRTY
Value used to indiate an "dirty" status in the metadata table. *

See Also:
Constant Field Values

JDBC_DRIVER_KEY

public static final String JDBC_DRIVER_KEY
Key used to specify a JDBC driver in the initialization parameters. *

See Also:
Constant Field Values

JDBC_URL_KEY

public static final String JDBC_URL_KEY
Key used to specify a JDBC URL in the initialization parameters. *

See Also:
Constant Field Values

USER_KEY

public static final String USER_KEY
Key used to specify a username in the initialization parameters. *

See Also:
Constant Field Values

PASSWORD_KEY

public static final String PASSWORD_KEY
Key used to specify a password in the initialization parameters. *

See Also:
Constant Field Values
Constructor Detail

RdfSource

public RdfSource()
Creates a new RdfSource object that will be able to read triples from an RDF database.

Method Detail

initialize

public void initialize(String jdbcDriver,
                       String jdbcUrl)
                throws SailInitializationException
Initializes the RdfSource.

Parameters:
jdbcDriver - The String representing the JDBC-driver class, e.g. org.gjt.mm.mysql.Driver.
jdbcUrl - The String representing the JDBC-url of the database to connect to, e.g. jdbc:mysql://localhost/sesame.
Throws:
SailInitializationException - If the initialization failed.

initialize

public void initialize(String jdbcDriver,
                       String jdbcUrl,
                       String user,
                       String password)
                throws SailInitializationException
Initializes the RdfSource.

Parameters:
jdbcDriver - The String representing the JDBC-driver class, e.g. org.gjt.mm.mysql.Driver.
jdbcUrl - The String representing the JDBC-url of the database to connect to, e.g. jdbc:mysql://localhost/sesame.
user - The username that can be used to connect to the RDBMS.
password - The password of the user in the RDBMS.
Throws:
SailInitializationException - If the initialization failed.

initialize

public void initialize(Map configParams)
                throws SailInitializationException
Initializes the RdfSource. Parameters can be specified using the keys defined by constants in this class: JDBC_DRIVER_KEY, JDBC_URL_KEY,USER_KEY and PASSWORD_KEY. See the other initialize() methods of this class for a description of the parameters and their values.

Specified by:
initialize in interface Sail
Parameters:
configParams - configuration parameters
Throws:
SailInitializationException - If the RdfSource could not be initialized using the supplied parameters.
See Also:
JDBC_DRIVER_KEY, JDBC_URL_KEY, USER_KEY, PASSWORD_KEY, initialize(java.lang.String,java.lang.String,java.lang.String,java.lang.String)

shutDown

public void shutDown()
Disconnects from the database.

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

getStatements

public StatementIterator getStatements(Resource subj,
                                       URI pred,
                                       Value obj,
                                       boolean explicitOnly)

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 query)
Merges all TriplePatterns to one large SQL-join and includes as much of the boolean constraints as possible.

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

hasStatement

public boolean hasStatement(Resource subj,
                            URI pred,
                            Value obj,
                            boolean explicitOnly)

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

getValue

public IdValue getValue(int id)
Gets the Value for the supplied ID.

Returns:
An IdValue object.

getResource

public IdResource getResource(int id)
Gets the Resource for the supplied ID.

Returns:
Either an IdURI or an IdBNode object

getLiteral

public IdLiteral getLiteral(int id)
Gets the Literal for the supplied ID.

Returns:
An IdLiteral object.

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.