Package helma.objectmodel.dom
Class XmlDatabase
- java.lang.Object
-
- helma.objectmodel.dom.XmlDatabase
-
-
Field Summary
Fields Modifier and Type Field Description protected Application
app
protected java.io.File
dbHomeDir
protected java.lang.String
encoding
protected XmlIDGenerator
idgen
protected NodeManager
nmgr
-
Constructor Summary
Constructors Constructor Description XmlDatabase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abortTransaction(ITransaction txn)
Abort the given transactionITransaction
beginTransaction()
Start a new transaction.void
commitTransaction(ITransaction txn)
committ the given transaction, makint its changes persistentvoid
deleteNode(ITransaction txn, java.lang.String kstr)
Marks an element from the database as deletedjava.lang.String
getEncoding()
get the file encoding used by this databaseXmlIDGenerator
getIDGenerator(ITransaction txn)
Get the id-generator for this database.INode
getNode(ITransaction txn, java.lang.String kstr)
Retrieves a Node from the database.void
init(java.io.File dbHome, Application app)
Initializes the database from an application.void
insertNode(ITransaction txn, java.lang.String kstr, INode node)
Save a node with the given key.java.lang.String
nextID()
Get the id for the next new object to be stored.void
saveIDGenerator(ITransaction txn)
Write the id-generator to file.void
setEncoding(java.lang.String encoding)
set the file encoding to usevoid
shutdown()
Shut down the databasevoid
updateNode(ITransaction txn, java.lang.String kstr, INode node)
Update a node with the given key.
-
-
-
Field Detail
-
dbHomeDir
protected java.io.File dbHomeDir
-
app
protected Application app
-
nmgr
protected NodeManager nmgr
-
idgen
protected XmlIDGenerator idgen
-
encoding
protected java.lang.String encoding
-
-
Method Detail
-
init
public void init(java.io.File dbHome, Application app) throws DatabaseException
Initializes the database from an application.- Specified by:
init
in interfaceIDatabase
- Parameters:
app
-- Throws:
DatabaseException
-
shutdown
public void shutdown()
Shut down the database
-
beginTransaction
public ITransaction beginTransaction() throws DatabaseException
Start a new transaction.- Specified by:
beginTransaction
in interfaceIDatabase
- Returns:
- the new tranaction object
- Throws:
DatabaseException
-
commitTransaction
public void commitTransaction(ITransaction txn) throws DatabaseException
committ the given transaction, makint its changes persistent- Specified by:
commitTransaction
in interfaceIDatabase
- Parameters:
txn
-- Throws:
DatabaseException
-
abortTransaction
public void abortTransaction(ITransaction txn) throws DatabaseException
Abort the given transaction- Specified by:
abortTransaction
in interfaceIDatabase
- Parameters:
txn
-- Throws:
DatabaseException
-
nextID
public java.lang.String nextID() throws ObjectNotFoundException
Get the id for the next new object to be stored.- Specified by:
nextID
in interfaceIDatabase
- Returns:
- the id for the next new object to be stored
- Throws:
ObjectNotFoundException
-
getIDGenerator
public XmlIDGenerator getIDGenerator(ITransaction txn) throws ObjectNotFoundException
Get the id-generator for this database.- Parameters:
txn
-- Returns:
- the id-generator for this database
- Throws:
ObjectNotFoundException
-
saveIDGenerator
public void saveIDGenerator(ITransaction txn) throws java.io.IOException
Write the id-generator to file.- Parameters:
txn
-- Throws:
java.io.IOException
-
getNode
public INode getNode(ITransaction txn, java.lang.String kstr) throws java.io.IOException, ObjectNotFoundException
Retrieves a Node from the database.- Specified by:
getNode
in interfaceIDatabase
- Parameters:
txn
- the current transactionkstr
- the key- Returns:
- the object associated with the given key
- Throws:
java.io.IOException
- if an I/O error occurred loading the object.ObjectNotFoundException
- if no object is stored by this key.
-
insertNode
public void insertNode(ITransaction txn, java.lang.String kstr, INode node) throws java.io.IOException
Save a node with the given key. Writes the node to a temporary file which is copied to its final name when the transaction is committed.- Specified by:
insertNode
in interfaceIDatabase
- Parameters:
txn
-kstr
-node
-- Throws:
java.io.IOException
-
updateNode
public void updateNode(ITransaction txn, java.lang.String kstr, INode node) throws java.io.IOException
Update a node with the given key. Writes the node to a temporary file which is copied to its final name when the transaction is committed.- Specified by:
updateNode
in interfaceIDatabase
- Parameters:
txn
-kstr
-node
-- Throws:
java.io.IOException
-
deleteNode
public void deleteNode(ITransaction txn, java.lang.String kstr) throws java.io.IOException
Marks an element from the database as deleted- Specified by:
deleteNode
in interfaceIDatabase
- Parameters:
txn
-kstr
-- Throws:
java.io.IOException
-
setEncoding
public void setEncoding(java.lang.String encoding)
set the file encoding to use- Parameters:
encoding
- the database's file encoding
-
getEncoding
public java.lang.String getEncoding()
get the file encoding used by this database- Returns:
- the file encoding used by this database
-
-