com.hp.hpl.mesa.rdf.jena.rdb
Class StoreRDB

java.lang.Object
  |
  +--com.hp.hpl.mesa.rdf.jena.common.StoreCom
        |
        +--com.hp.hpl.mesa.rdf.jena.rdb.StoreRDB
All Implemented Interfaces:
Store

public class StoreRDB
extends StoreCom
implements Store

Generic store implementation for RDB backed RDF storage. The underlying database operations are implemented by separate driver classes which conform to the IRDBDriver interface. Different driver instances may support different database table layouts as well as different specific databases.

A single driver instance can be shared by several StoreRDB instances whereas each ModelRDB requires a separate StoreRDB instance.

Version:
$Revision: 1.6 $ on $Date: 2002/08/09 12:12:50 $
Author:
Dave Reynolds

Method Summary
 void abort()
          Abort the current transaction and abandon any changes in progress.
 void add(Statement s)
          Add a new statement to the model and load it to the database
 void attachModel(ModelRDB m)
          Note the model which this store is associated with.
 void begin()
          Begin a new transation.
 void clear()
          Remove all the statements from the database.
 void close()
          Close this store
 void commit()
          Commit the current transaction.
 boolean contains(Resource s, Property p)
          Return true if the model contains at least one statement with this subject/property pair
 boolean contains(Statement s)
          Return true if the model contains a statements corresponding this triple
 IConstraints createConstraints(ModelRDB model)
          Create a constraint object appropriate for this type of database layout
static StoreRDB createDB(IRDBDriver driver)
          Construct a new Store using the given database spec.
 Property createProperty(java.lang.String uri, Model m)
          Create a new property resource implementation for a model
 Property createProperty(java.lang.String namespace, java.lang.String localPart, Model m)
          Create a new property resource implementation for a model
 Resource createResource(Model m)
          Create a new resource implementation for a model
 Resource createResource(java.lang.String uri, Model m)
          Create a new resource implementation for a model
 Statement createStatement(Resource s, Property p, RDFNode o, Model m)
          create a new statement implementation for a model
 IRDBDriver getDriver()
          Return the database driver underpining this store
 Property getProperty(Property p)
          Fetch a property, adding it to the database if necessary
 Resource getResource(java.lang.String uri, Model m)
          Fetch a resource, adding it to the database if necessary
 java.util.Iterator list()
          List all the statements in this model
 java.util.Iterator list(Resource subject, Property predicate, RDFNode object)
          List all statements with this s/p/o combination.
 java.util.Iterator listByObject(RDFNode object)
          List all statements in the model with this object
 java.util.Iterator listByPredicate(Property property)
          List all statements in the model with this predicate
 java.util.Iterator listBySubject(Resource subject)
          List all statements in the model with this subject
 NsIterator listNameSpaces()
          list namespaces of the predicates of all the statements in ths store.
 ResultSetIterator listReifiedStatements(ModelRDB m)
          Return an iterator over all statements which are have been added as reified statements.
 ResultSetIterator listStatements(IConstraints constraints, ModelRDB m)
          List all the statements in the given moddel which make the given set of constraints (a constraint set can be obtained using createConstraints(com.hp.hpl.mesa.rdf.jena.rdb.ModelRDB)).
 ResIterator listSubjects()
          List all the subject resources in the model
static StoreRDB openDB(IRDBDriver driver)
          Open a named database and check that it is formated for RDF storage.
 void remove(Statement s)
          remove a statement from the store
 int size()
          Return the total number of statements in the model by a brute force - list and count!
 boolean supportsJenaReification()
          Returns true if the database layout supports implicit reification of statements (i.e.
 
Methods inherited from class com.hp.hpl.mesa.rdf.jena.common.StoreCom
createAlt, createAlt, createBag, createBag, createSeq, createSeq, getAlt, getAlt, getBag, getBag, getProperty, getProperty, getSeq, getSeq, getStatement
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.hp.hpl.mesa.rdf.jena.common.Store
createAlt, createAlt, createBag, createBag, createSeq, createSeq, getAlt, getAlt, getBag, getBag, getProperty, getProperty, getSeq, getSeq, getStatement
 

Method Detail

createDB

public static StoreRDB createDB(IRDBDriver driver)
                         throws RDFRDBException
Construct a new Store using the given database spec. If the database exists but does not seem to be formated for RDF storage new tables will be created.

Parameters:
driver - defines the database driver, host machine, login details and root path for the databases.
Returns:
the RDB-based Store
Throws:
RDFRDBException - if the database cannot be opened

openDB

public static StoreRDB openDB(IRDBDriver driver)
                       throws RDFRDBException
Open a named database and check that it is formated for RDF storage.

Returns:
the RDB-based Store
Throws:
RDFRDBException - if the database cannot be opened or if once opened it does not seem to contain a valid set of RDF storage tables.

attachModel

public void attachModel(ModelRDB m)
Note the model which this store is associated with.


getDriver

public IRDBDriver getDriver()
Return the database driver underpining this store


close

public void close()
Close this store

Specified by:
close in interface Store
Overrides:
close in class StoreCom

clear

public void clear()
           throws RDFRDBException
Remove all the statements from the database. This no longer reformats the database (which makes it safer) but means that it is not guaranteed to garbage collect the resource table.

RDFRDBException

begin

public void begin()
           throws RDFException
Begin a new transation.

All changes made to a model within a transaction, will either be made, or none of them will be made.

Returns:
this model to enable cascading.
Throws:
RDFException - Generic RDF Exception

abort

public void abort()
           throws RDFException
Abort the current transaction and abandon any changes in progress.

Returns:
this model to enable cascading.
Throws:
RDFException - Generic RDF Exception

commit

public void commit()
            throws RDFException
Commit the current transaction.

Returns:
this model to enable cascading.
Throws:
RDFException - Generic RDF Exception

createResource

public Resource createResource(Model m)
                        throws RDFException
Create a new resource implementation for a model

Specified by:
createResource in interface Store
Overrides:
createResource in class StoreCom
RDFException

createResource

public Resource createResource(java.lang.String uri,
                               Model m)
                        throws RDFException
Create a new resource implementation for a model

Specified by:
createResource in interface Store
Overrides:
createResource in class StoreCom
RDFException

createProperty

public Property createProperty(java.lang.String uri,
                               Model m)
                        throws RDFException
Create a new property resource implementation for a model

Specified by:
createProperty in interface Store
Overrides:
createProperty in class StoreCom
RDFException

createProperty

public Property createProperty(java.lang.String namespace,
                               java.lang.String localPart,
                               Model m)
                        throws RDFException
Create a new property resource implementation for a model

Specified by:
createProperty in interface Store
Overrides:
createProperty in class StoreCom
RDFException

createStatement

public Statement createStatement(Resource s,
                                 Property p,
                                 RDFNode o,
                                 Model m)
                          throws RDFException
create a new statement implementation for a model

Specified by:
createStatement in interface Store
Overrides:
createStatement in class StoreCom
RDFException

getResource

public Resource getResource(java.lang.String uri,
                            Model m)
                     throws RDFException
Fetch a resource, adding it to the database if necessary

Specified by:
getResource in interface Store
Overrides:
getResource in class StoreCom
RDFException

getProperty

public Property getProperty(Property p)
                     throws RDFException
Fetch a property, adding it to the database if necessary

Specified by:
getProperty in interface Store
Overrides:
getProperty in class StoreCom
RDFException

add

public void add(Statement s)
         throws RDFException
Add a new statement to the model and load it to the database

Specified by:
add in interface Store
Parameters:
s - the statement to add
RDFException

remove

public void remove(Statement s)
            throws RDFException
Description copied from interface: Store
remove a statement from the store

Specified by:
remove in interface Store
Parameters:
s - the statement to remove
RDFException

size

public int size()
         throws RDFException
Return the total number of statements in the model by a brute force - list and count!

Specified by:
size in interface Store
Returns:
the number of statements in the store
RDFException

contains

public boolean contains(Statement s)
                 throws RDFException
Return true if the model contains a statements corresponding this triple

Specified by:
contains in interface Store
Parameters:
s - the statement to test for
Returns:
true if the statement is in the store, false otherwise
RDFException

contains

public boolean contains(Resource s,
                        Property p)
                 throws RDFException
Return true if the model contains at least one statement with this subject/property pair

Specified by:
contains in interface Store
Parameters:
s - the subject of the statement to test for
p - the predicate of the statement to test for
Returns:
true if the statement is in the store, false otherwise
RDFException

list

public java.util.Iterator list()
                        throws RDFException
List all the statements in this model

Specified by:
list in interface Store
Returns:
in iterator over all the statements in the store
RDFException

list

public java.util.Iterator list(Resource subject,
                               Property predicate,
                               RDFNode object)
                        throws RDFException
List all statements with this s/p/o combination. Any argument can be null which corresponds to a wildcard.

Specified by:
list in interface Store
Parameters:
subject - the subject of the statements to be returned or null
predicate - the predicate of the statments to be returned or null
object - the object of the statements to be returned or null
Returns:
an iterator over all statements in the store which match the given subject predicate and object
RDFException

listStatements

public ResultSetIterator listStatements(IConstraints constraints,
                                        ModelRDB m)
                                 throws RDFException
List all the statements in the given moddel which make the given set of constraints (a constraint set can be obtained using createConstraints(com.hp.hpl.mesa.rdf.jena.rdb.ModelRDB)).

RDFException

createConstraints

public IConstraints createConstraints(ModelRDB model)
Create a constraint object appropriate for this type of database layout


listBySubject

public java.util.Iterator listBySubject(Resource subject)
                                 throws RDFException
List all statements in the model with this subject

Specified by:
listBySubject in interface Store
Parameters:
subject - the subject of the statements to be returned
Returns:
an iterator over all statements in the store with the given subject
RDFException

listByPredicate

public java.util.Iterator listByPredicate(Property property)
                                   throws RDFException
List all statements in the model with this predicate

Specified by:
listByPredicate in interface Store
Parameters:
property - the predicate to search for
Returns:
an iterator over all statements in the store with the given predicate
RDFException

listByObject

public java.util.Iterator listByObject(RDFNode object)
                                throws RDFException
List all statements in the model with this object

Specified by:
listByObject in interface Store
Parameters:
object - the object to search for
Returns:
an iterator over all statements in the store with the given object
RDFException

listSubjects

public ResIterator listSubjects()
                         throws RDFException
List all the subject resources in the model

Specified by:
listSubjects in interface Store
Returns:
ResIterator over Resource objects
RDFException

listNameSpaces

public NsIterator listNameSpaces()
                          throws RDFException
Description copied from interface: Store
list namespaces of the predicates of all the statements in ths store.

Each namespace is listed only once.

Specified by:
listNameSpaces in interface Store
Returns:
an iterator over a set of the subjects of all statements in the store
RDFException

supportsJenaReification

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


listReifiedStatements

public ResultSetIterator listReifiedStatements(ModelRDB m)
                                        throws RDFException
Return an iterator over all statements which are have been added as reified statements. Defect: The current implementation will not notice if all references to a reified statement have been removed.

RDFException


Copyright © 2001 Hewlett-Packard. All Rights Reserved.