Package helma.objectmodel.dom
Class XmlDatabase
java.lang.Object
helma.objectmodel.dom.XmlDatabase
- All Implemented Interfaces:
IDatabase
A simple XML-database
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Application
protected File
protected String
protected XmlIDGenerator
protected NodeManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Abort the given transactionStart a new transaction.void
committ the given transaction, makint its changes persistentvoid
deleteNode
(ITransaction txn, String kstr) Marks an element from the database as deletedget the file encoding used by this databaseGet the id-generator for this database.getNode
(ITransaction txn, String kstr) Retrieves a Node from the database.void
init
(File dbHome, Application app) Initializes the database from an application.void
insertNode
(ITransaction txn, String kstr, INode node) Save a node with the given key.nextID()
Get the id for the next new object to be stored.void
Write the id-generator to file.void
setEncoding
(String encoding) set the file encoding to usevoid
shutdown()
Shut down the databasevoid
updateNode
(ITransaction txn, String kstr, INode node) Update a node with the given key.
-
Field Details
-
dbHomeDir
-
app
-
nmgr
-
idgen
-
encoding
-
-
Constructor Details
-
XmlDatabase
public XmlDatabase()
-
-
Method Details
-
init
Initializes the database from an application.- Specified by:
init
in interfaceIDatabase
- Parameters:
dbHome
-app
-- Throws:
DatabaseException
-
shutdown
public void shutdown()Shut down the database -
beginTransaction
Start a new transaction.- Specified by:
beginTransaction
in interfaceIDatabase
- Returns:
- the new tranaction object
- Throws:
DatabaseException
-
commitTransaction
committ the given transaction, makint its changes persistent- Specified by:
commitTransaction
in interfaceIDatabase
- Parameters:
txn
-- Throws:
DatabaseException
-
abortTransaction
Abort the given transaction- Specified by:
abortTransaction
in interfaceIDatabase
- Parameters:
txn
-- Throws:
DatabaseException
-
nextID
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
Get the id-generator for this database.- Parameters:
txn
-- Returns:
- the id-generator for this database
- Throws:
ObjectNotFoundException
-
saveIDGenerator
Write the id-generator to file.- Parameters:
txn
-- Throws:
IOException
-
getNode
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:
IOException
- if an I/O error occurred loading the object.ObjectNotFoundException
- if no object is stored by this key.
-
insertNode
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:
IOException
-
updateNode
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:
IOException
-
deleteNode
Marks an element from the database as deleted- Specified by:
deleteNode
in interfaceIDatabase
- Parameters:
txn
-kstr
-- Throws:
IOException
-
setEncoding
set the file encoding to use- Parameters:
encoding
- the database's file encoding
-
getEncoding
get the file encoding used by this database- Returns:
- the file encoding used by this database
-