com.hp.hpl.jena.db.impl
Interface IRDBDriver

All Known Implementing Classes:
DriverRDB

public interface IRDBDriver

Generic database interface used for implementing RDF Stores. Different database table layouts and different SQL dialects should all be supportable via this generic interface. In earlier versions of Jena the Driver was exposed to some applications - that is no longer the case, and no application should need to use these functions directly. Based in part on the Jena 1.0 implementation by der.

Version:
$Revision: 1.1 $
Author:
csayers

Nested Class Summary
static class IRDBDriver.GenSQLAnd
           
 
Method Summary
 void abort()
          Aborts the open transaction, then turns autocommit on.
 void begin()
          Turns autocommit off, then opens a new transaction
 void cleanDB()
          Remove all RDF information from a database.
 void close()
          Close the databse connection.
 void commit()
          Commits the open transaction, then turns autocommit on.
 List createSpecializedGraphs(DBPropGraph graphProperties)
          Construct and return a list of specialized graphs.
 String createTable(int graphId, boolean isReif)
          Create a table for storing asserted or reified statements.
 void formatDB()
          Deprecated. Since Jena 2.0 this call is no longer needed - formatting happens automatically as a side effect of creating Models - there should be no need for an application to interact directly with the driver.
 String genSQLFromList(int aliasCnt, String table)
          Generate an SQL string for a from list of a select stmt.
 String genSQLJoin(int lhsAlias, char lhsCol, int rhsAlias, char rhsCol)
          Generate an SQL string to joing two table columns.
 String genSQLQualConst(int alias, char col, Node lit)
          Generate an SQL string to match a table column value to a constant.
 String genSQLQualGraphId(int alias, int graphId)
          Generate an SQL string to match a graph id.
 String genSQLQualParam(int alias, char col)
          Generate an SQL string to match a table column value to a parameter.
 String genSQLReifQualAnyObj(boolean objIsStmt)
          Generate an SQL string for a reified statement to match on any subject, predicate or object column.
 String genSQLReifQualObj(char reifProp, boolean hasObj)
          Generate an SQL string for a reified statement to match on a property column.
 String genSQLReifQualStmt()
          Generate an SQL string for a reified statement to match on the stmt URI.
 String genSQLResList(int[] resIndex, VarIndex[] binding)
          Generate an SQL string for a result list of a select stmt.
 String genSQLSelectStmt(String res, String from, String where)
          Generate an SQL Select statement given the result list, the from list and the where clause;
 boolean getBatchEnabled()
          Get the value of BatchEnabled
 int getCompressCacheSize()
          Get the value of CompressCacheSize
 int getCompressURILength()
          Get the value of CompressURILength
 IDBConnection getConnection()
          Return the connection
 String getDatabaseType()
          Return a string identifying underlying database type.
 DBPropGraph getDefaultModelProperties()
          Obtain a default set of model properties.
 boolean getDoCompressURI()
          Get the value of DoCompressURI
 boolean getDoDuplicateCheck()
          Get the value of DoDuplicateCheck
 int getIndexKeyLength()
          Get the value of IndexKeyLength
 int getInsertID(String tableName)
          Return an auto-generated identifier for a table row.
 boolean getIsTransactionDb()
          Get the value of IsTransactionDb
 int getLongObjectLength()
          Get the value of LongObjectLength
 String getStoreWithModel()
          Get the value of StoreWithModel
 SpecializedGraph getSystemSpecializedGraph()
          Return the specialized graph containing system properties.
 String getTableNamePrefix()
          Get the value of TableNamePrefix
 int graphIdAlloc(String graphName)
          Allocate an identifier for a new graph.
 void graphIdDealloc(int graphId)
          Deallocate an identifier for a new graph.
 boolean isDBFormatOK()
          Test if the database has previously been formatted (there's no other way to easily tell, since getSpecializedGraph will always return something).
 String nodeToRDBString(Node node, boolean addIfLong)
          Convert a node to a string to be stored in a statement table.
 Node RDBStringToNode(String RDBString)
          Convert an RDB string to the node that it encodes.
 List recreateSpecializedGraphs(DBPropGraph graphProperties)
          Reconstruct and return a list of specialized graphs.
 void removeSpecializedGraphs(DBPropGraph graphProperties, List specializedGraphs)
          Remove the specialized graph, erasing all trace of a Graph.
 void setBatchEnabled(boolean bool)
          Set the value of BatchEnabled
 void setCompressCacheSize(int count)
          Set the value of CompressCacheSize.
 void setCompressURILength(int len)
          Set the value of CompressURILength.
 void setConnection(IDBConnection dbcon)
          Set the database connection
 void setDatabaseProperties(Graph databaseProperties)
          Method setDatabaseProperties.
 void setDoCompressURI(boolean bool)
          Set the value of DoCompressURI.
 void setDoDuplicateCheck(boolean bool)
          Set the value of DoDuplicateCheck.
 void setIndexKeyLength(int len)
          Set the value of IndexKeyLength.
 void setIsTransactionDb(boolean bool)
          Set the value of IsTransactionDb.
 void setLongObjectLength(int len)
          Set the value of LongObjectLength.
 void setStoreWithModel(String modelName)
          Set the value of StoreWithModel.
 void setTableNamePrefix(String prefix)
          Set the value of TableNamePrefix.
 boolean supportsJenaReification()
          Deprecated. Since Jena 2.0 the reification API has changed. The new API is supported in all models, but the old Jena 1 API is no longer supported. This call will return false to indicate to old code that the old style of jena reification is not supported.
 boolean supportsMultipleModels()
          Deprecated. Since Jena 2.0 all databases support multiple models.
 boolean transactionsSupported()
          Returns true if the underlying database supports transactions.
 

Method Detail

setConnection

public void setConnection(IDBConnection dbcon)
Set the database connection


getConnection

public IDBConnection getConnection()
Return the connection


getSystemSpecializedGraph

public SpecializedGraph getSystemSpecializedGraph()
Return the specialized graph containing system properties. Formats the databaase and constucts a new one if necessary.

Returns:
SpecializedGraph holding properties of this database
Since:
Jena 2.0

createSpecializedGraphs

public List createSpecializedGraphs(DBPropGraph graphProperties)
Construct and return a list of specialized graphs.

Parameters:
graphProperties - A set of customization properties for the graph.
Returns:
List of SpecializedGraphs to store a Graph
Since:
Jena 2.0

recreateSpecializedGraphs

public List recreateSpecializedGraphs(DBPropGraph graphProperties)
Reconstruct and return a list of specialized graphs.

Parameters:
graphProperties - A set of customization properties for the graph.
Returns:
List of SpecializedGraphs to store a Graph
Since:
Jena 2.0

removeSpecializedGraphs

public void removeSpecializedGraphs(DBPropGraph graphProperties,
                                    List specializedGraphs)
Remove the specialized graph, erasing all trace of a Graph.

Parameters:
graphProperties - The properties for the graph to be removed.
Since:
Jena 2.0

isDBFormatOK

public boolean isDBFormatOK()
Test if the database has previously been formatted (there's no other way to easily tell, since getSpecializedGraph will always return something).

Returns:
boolean true if database is correctly formatted, false on any error.

setDatabaseProperties

public void setDatabaseProperties(Graph databaseProperties)
Method setDatabaseProperties. Sets the current properties for the database.

Parameters:
databaseProperties - is a Graph containing a full set of database properties

getDefaultModelProperties

public DBPropGraph getDefaultModelProperties()
Obtain a default set of model properties. Return the default properties for a new model stored in this database

Returns:
DBPropGraph containg the default properties for a new model

getDatabaseType

public String getDatabaseType()
Return a string identifying underlying database type.


cleanDB

public void cleanDB()
Remove all RDF information from a database. There should be no need for an application to call this function directly - instead use DBConnection.cleanDB().


close

public void close()
           throws RDFRDBException
Close the databse connection.

Throws:
RDFDBException - if there is an access problem
RDFRDBException

formatDB

public void formatDB()
              throws RDFRDBException
Deprecated. Since Jena 2.0 this call is no longer needed - formatting happens automatically as a side effect of creating Models - there should be no need for an application to interact directly with the driver.

Initialise a database ready to store RDF tables. Currently the table format depends on the RDBSpec type. In future it may become an explicit part of operations like this.

Throws:
RDFDBException - if the is a problem opening the connection or an internal SQL error.
RDFRDBException

createTable

public String createTable(int graphId,
                          boolean isReif)
Create a table for storing asserted or reified statements.

Parameters:
graphId - the graph which the table is created.
isReif - true if table stores reified statements.
Returns:
the name of the new table

abort

public void abort()
           throws RDFRDBException
Aborts the open transaction, then turns autocommit on.

Throws:
RDFRDBException

begin

public void begin()
           throws RDFRDBException
Turns autocommit off, then opens a new transaction. *

Throws:
RDFRDBException

commit

public void commit()
            throws RDFRDBException
Commits the open transaction, then turns autocommit on.

Throws:
RDFRDBException

transactionsSupported

public boolean transactionsSupported()
Returns true if the underlying database supports transactions.


supportsMultipleModels

public boolean supportsMultipleModels()
Deprecated. Since Jena 2.0 all databases support multiple models.

Returns true if the database layout supports multiple RDF models in the same database.

Returns:
boolean true if the database supports multiple models

supportsJenaReification

public boolean supportsJenaReification()
Deprecated. Since Jena 2.0 the reification API has changed. The new API is supported in all models, but the old Jena 1 API is no longer supported. This call will return false to indicate to old code that the old style of jena reification is not supported.

Returns true if the database layout supports implicit reification. of statements (i.e. statements can be treated as resources).

Returns:
boolean true if the database supports jena 1.0 reification.

graphIdAlloc

public int graphIdAlloc(String graphName)
Allocate an identifier for a new graph.

Parameters:
graphName - The name of a new graph.
Returns:
the identifier of the new graph.

graphIdDealloc

public void graphIdDealloc(int graphId)
Deallocate an identifier for a new graph.

Parameters:
graphId - The graph identifier.

getInsertID

public int getInsertID(String tableName)
Return an auto-generated identifier for a table row.

Parameters:
tableName - The name of the table for the insert.
Returns:
the auto-generated identifier..

nodeToRDBString

public String nodeToRDBString(Node node,
                              boolean addIfLong)
Convert a node to a string to be stored in a statement table.

Parameters:
addIfLong - If the node is a long object and is not in the database, add it.
Returns:
the string.

RDBStringToNode

public Node RDBStringToNode(String RDBString)
Convert an RDB string to the node that it encodes. Return null if failure.

Returns:
The node.

genSQLReifQualStmt

public String genSQLReifQualStmt()
Generate an SQL string for a reified statement to match on the stmt URI.

Returns:
qualifier string

genSQLReifQualAnyObj

public String genSQLReifQualAnyObj(boolean objIsStmt)
Generate an SQL string for a reified statement to match on any subject, predicate or object column.

Parameters:
objIsStmt - If true, the object value is rdf:Statement so also match on the hasType column.
Returns:
qualifier string

genSQLReifQualObj

public String genSQLReifQualObj(char reifProp,
                                boolean hasObj)
Generate an SQL string for a reified statement to match on a property column.

Parameters:
reifProp - The property column to match, one of S,P,O,T for subject, predicate, object or type, respectively.
hasObj - If true, the object value is known so do equality match. Otherwise, just check for non-null value.
Returns:
qualifier string

genSQLQualConst

public String genSQLQualConst(int alias,
                              char col,
                              Node lit)
Generate an SQL string to match a table column value to a constant. If the literal does not occur in the database, a match condition is generated that will always return false. There's a known bug in this method. the literal is converted to a string BEFORE the query is run. consequently, there's a race condition. if the (long) literal is not in the database when the query is compiled but is added prior to running the query, then the query will (incorrectly) return no results. for now, we'll ignore this case and document it as a bug.

Parameters:
alias - The table alias for this match.
col - The column to match, one of S,P,O,N,T for subject, predicate, object, statement or type, respectively.
lit - The literal value to match.
Returns:
SQL string.

genSQLQualParam

public String genSQLQualParam(int alias,
                              char col)
Generate an SQL string to match a table column value to a parameter.

Parameters:
alias - The table alias for this match.
col - The column to match, one of S,P,O,N,T for subject, predicate, object, statement or type, respectively.
Returns:
SQL string.

genSQLQualGraphId

public String genSQLQualGraphId(int alias,
                                int graphId)
Generate an SQL string to match a graph id.

Parameters:
alias - The table alias for this match.
graphId - The identifer of the graph to match.
Returns:
SQL string.

genSQLJoin

public String genSQLJoin(int lhsAlias,
                         char lhsCol,
                         int rhsAlias,
                         char rhsCol)
Generate an SQL string to joing two table columns.

Parameters:
lhsAlias - The left side table alias for the join.
lhsCol - The left side column to join, one of S,P,O,N,T.
rhsAlias - The right side table alias to join.
rhsCol - The right side column to join.
Returns:
SQL string.

genSQLResList

public String genSQLResList(int[] resIndex,
                            VarIndex[] binding)
Generate an SQL string for a result list of a select stmt.

Parameters:
binding - Array of Var containing the result list bindings.
Returns:
SQL string (not prefixed by "Select").

genSQLFromList

public String genSQLFromList(int aliasCnt,
                             String table)
Generate an SQL string for a from list of a select stmt.

Parameters:
aliasCnt - The number of table aliases in the from list.
table - The name of the table to be queried.
Returns:
SQL string (not prefixed by "From").

genSQLSelectStmt

public String genSQLSelectStmt(String res,
                               String from,
                               String where)
Generate an SQL Select statement given the result list, the from list and the where clause;

Parameters:
res - The result list as a string.
from - The from list as a string.
where - The where qualifier as a string.
Returns:
SQL statement.

getLongObjectLength

public int getLongObjectLength()
Get the value of LongObjectLength

Returns:
int

setLongObjectLength

public void setLongObjectLength(int len)
Set the value of LongObjectLength. Throws an exception if the database has been initialized.


getIndexKeyLength

public int getIndexKeyLength()
Get the value of IndexKeyLength

Returns:
int

setIndexKeyLength

public void setIndexKeyLength(int len)
Set the value of IndexKeyLength. Throws an exception if the database has been initialized.


getIsTransactionDb

public boolean getIsTransactionDb()
Get the value of IsTransactionDb

Returns:
bool

setIsTransactionDb

public void setIsTransactionDb(boolean bool)
Set the value of IsTransactionDb. Throws an exception if the database has been initialized.

Parameters:
bool -

getDoCompressURI

public boolean getDoCompressURI()
Get the value of DoCompressURI

Returns:
bool

setDoCompressURI

public void setDoCompressURI(boolean bool)
Set the value of DoCompressURI. Throws an exception if the database has been initialized.

Parameters:
bool -

getCompressURILength

public int getCompressURILength()
Get the value of CompressURILength

Returns:
int

setCompressURILength

public void setCompressURILength(int len)
Set the value of CompressURILength. Throws an exception if the database has been initialized.


getDoDuplicateCheck

public boolean getDoDuplicateCheck()
Get the value of DoDuplicateCheck

Returns:
bool

setDoDuplicateCheck

public void setDoDuplicateCheck(boolean bool)
Set the value of DoDuplicateCheck.

Parameters:
bool -

getTableNamePrefix

public String getTableNamePrefix()
Get the value of TableNamePrefix

Returns:
String

setTableNamePrefix

public void setTableNamePrefix(String prefix)
Set the value of TableNamePrefix.


getStoreWithModel

public String getStoreWithModel()
Get the value of StoreWithModel

Returns:
String

setStoreWithModel

public void setStoreWithModel(String modelName)
Set the value of StoreWithModel.


getCompressCacheSize

public int getCompressCacheSize()
Get the value of CompressCacheSize

Returns:
int

setCompressCacheSize

public void setCompressCacheSize(int count)
Set the value of CompressCacheSize.


getBatchEnabled

public boolean getBatchEnabled()
Get the value of BatchEnabled

Returns:
bool

setBatchEnabled

public void setBatchEnabled(boolean bool)
Set the value of BatchEnabled

Parameters:
bool -


Copyright © 2003 SCAM. All Rights Reserved.