## helma.objectmodel.dom
Class XmlDatabase

    java.lang.Object
      helma.objectmodel.dom.XmlDatabase

All Implemented Interfaces:
  IDatabase

    public final class XmlDatabase

extends java.lang.Object
implements IDatabase

A simple XML-database

Field Summary
`protected Application` `app`
`protected java.io.File` `dbHomeDir`
`protected java.lang.String` `encoding`
`protected XmlIDGenerator` `idgen`
`protected NodeManager` `nmgr`

Constructor Summary
`XmlDatabase()`

Method Summary
`void` `abortTransaction(ITransaction txn)` Abort the given transaction
`ITransaction` `beginTransaction()` Start a new transaction.
`void` `commitTransaction(ITransaction txn)` committ the given transaction, makint its changes persistent
`void` `deleteNode(ITransaction txn, java.lang.String kstr)` Marks an element from the database as deleted
`java.lang.String` `getEncoding()` get the file encoding used by this database
`XmlIDGenerator` `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 use
`void` `shutdown()` Shut down the database
`void` `updateNode(ITransaction txn, java.lang.String kstr, INode node)` Update a node with the given key.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

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

Constructor Detail

### XmlDatabase

    public XmlDatabase()

Method Detail

### init

    public void init(java.io.File dbHome,
                     Application app)
              throws DatabaseException

  Initializes the database from an application.

  Specified by:
    `init` in interface `IDatabase`
  Parameters:
    `app` -
  Throws:
    `DatabaseException`

### shutdown

    public void shutdown()

  Shut down the database

  Specified by:
    `shutdown` in interface `IDatabase`

### beginTransaction

    public ITransaction beginTransaction()
                                  throws DatabaseException

  Start a new transaction.

  Specified by:
    `beginTransaction` in interface `IDatabase`
  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 interface `IDatabase`
  Parameters:
    `txn` -
  Throws:
    `DatabaseException`

### abortTransaction

    public void abortTransaction(ITransaction txn)
                          throws DatabaseException

  Abort the given transaction

  Specified by:
    `abortTransaction` in interface `IDatabase`
  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 interface `IDatabase`
  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 interface `IDatabase`
  Parameters:
    `txn` - the current transaction
    `kstr` - 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 interface `IDatabase`
  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 interface `IDatabase`
  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 interface `IDatabase`
  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

Copyright © 1998-1998-${year} Helma.org. All Rights Reserved.