org.xorm.datastore.xml
Class JDOMDocumentDriver

java.lang.Object
  |
  +--org.xorm.datastore.xml.JDOMDocumentDriver
All Implemented Interfaces:
DatastoreDriver

public class JDOMDocumentDriver
extends Object
implements DatastoreDriver

A datastore driver that uses an XML document as the datastore. Datastore XML descriptor files need to specify a column named "." as the primary key column; table names should match element names. Data column names should be specified in a limited XPath notation. Examples are "@name", "description/text()", and ".." for a parent reference. This class relies on the transactional mechanics of the DocumentHolder class. At the beginning of each transaction, it acquires a document by calling checkout(); upon commit (but not rollback) it calls checkin().

Author:
Wes Biggs

Constructor Summary
JDOMDocumentDriver(DocumentHolder documentHolder)
          Sets the data source, which must be an instance of DocumentHolder.
 
Method Summary
 void begin(boolean readOnly)
          Begins a transaction by calling checkout on the DocumentHolder.
 void commit()
          Calls checkin() on the DocumentHolder if any write operations were called during the transaction.
 int count(Selector selector)
          Returns the size of the results that would be returned by the query.
 void create(Row row)
          Creates (inserts) a new row in the datastore.
 void delete(Row row)
          Permanently deletes a single row from the datastore.
 void rollback()
           
 Collection select(Selector selector, Set extraRows)
          Selects from (queries) the datastore for rows matching the specified query conditions.
 void update(Row row)
          Updates a given row so that the datastore's values are in sync with those in the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDOMDocumentDriver

public JDOMDocumentDriver(DocumentHolder documentHolder)
Sets the data source, which must be an instance of DocumentHolder.

Method Detail

begin

public void begin(boolean readOnly)
Begins a transaction by calling checkout on the DocumentHolder.

Specified by:
begin in interface DatastoreDriver

commit

public void commit()
            throws DriverException
Calls checkin() on the DocumentHolder if any write operations were called during the transaction.

Specified by:
commit in interface DatastoreDriver
DriverException

rollback

public void rollback()
Specified by:
rollback in interface DatastoreDriver

create

public void create(Row row)
Description copied from interface: DatastoreDriver
Creates (inserts) a new row in the datastore. If the table is configured for autoincrement or sequence ID generation, the object ID is generated using that method before the row is inserted.

Specified by:
create in interface DatastoreDriver

update

public void update(Row row)
Description copied from interface: DatastoreDriver
Updates a given row so that the datastore's values are in sync with those in the object.

Specified by:
update in interface DatastoreDriver

delete

public void delete(Row row)
Description copied from interface: DatastoreDriver
Permanently deletes a single row from the datastore.

Specified by:
delete in interface DatastoreDriver

select

public Collection select(Selector selector,
                         Set extraRows)
Description copied from interface: DatastoreDriver
Selects from (queries) the datastore for rows matching the specified query conditions.

Specified by:
select in interface DatastoreDriver
Parameters:
selector - the root of the parse tree representing the query
extraRows - a non-null set to which additional objects read from the datastore can be added, as advised by fetch group information and optimization choices.
Returns:
a collection of Row objects matching the selection criteria.

count

public int count(Selector selector)
Description copied from interface: DatastoreDriver
Returns the size of the results that would be returned by the query. A naive implementation would be to return select(selector, ...).size(). However, this allows datastores that provide a native count feature to use far less network and memory resources.

Specified by:
count in interface DatastoreDriver


$Header: /cvsroot/xorm/xorm/docs/api/org/xorm/datastore/xml/JDOMDocumentDriver.html,v 1.6 2004/05/30 08:55:07 wbiggs Exp $