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.2 $ on $Date: 2001/11/26 18:20:10 $
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 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
 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 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!
 
Methods inherited from class com.hp.hpl.mesa.rdf.jena.common.StoreCom
createAlt, createAlt, createBag, createBag, createSeq, createSeq, createStatement, 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, createStatement, 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.
Parameters:
driverpec - 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 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

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

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

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

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

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

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

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
Following copied from interface: com.hp.hpl.mesa.rdf.jena.common.Store
Parameters:
s - the statement to add

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
Following copied from interface: com.hp.hpl.mesa.rdf.jena.common.Store
Parameters:
s - the statement to remove

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
Following copied from interface: com.hp.hpl.mesa.rdf.jena.common.Store
Returns:
the number of statements in the store

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
Following copied from interface: com.hp.hpl.mesa.rdf.jena.common.Store
Parameters:
s - the statement to test for
Returns:
true if the statement is in the store, false otherwise

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
Following copied from interface: com.hp.hpl.mesa.rdf.jena.common.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

list

public java.util.Iterator list()
                        throws RDFException
List all the statements in this model
Specified by:
list in interface Store
Following copied from interface: com.hp.hpl.mesa.rdf.jena.common.Store
Returns:
in iterator over all the statements in the store

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
Following copied from interface: com.hp.hpl.mesa.rdf.jena.common.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

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

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
Following copied from interface: com.hp.hpl.mesa.rdf.jena.common.Store
Parameters:
subject - the subject of the statements to be returned
Returns:
an iterator over all statements in the store with the given subject

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
Following copied from interface: com.hp.hpl.mesa.rdf.jena.common.Store
Parameters:
property - the predicate to search for
Returns:
an iterator over all statements in the store with the given predicate

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
Following copied from interface: com.hp.hpl.mesa.rdf.jena.common.Store
Parameters:
object - the object to search for
Returns:
an iterator over all statements in the store with the given object

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

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
Following copied from interface: com.hp.hpl.mesa.rdf.jena.common.Store
Returns:
an iterator over a set of the subjects of all statements in the store


Copyright 2001 Hewlett-Packard. All Rights Reserved.