Class XmlDatabase

  • All Implemented Interfaces:
    IDatabase

    public final class XmlDatabase
    extends java.lang.Object
    implements IDatabase
    A simple XML-database
    • Constructor Detail

      • XmlDatabase

        public XmlDatabase()
    • Method Detail

      • shutdown

        public void shutdown()
        Shut down the database
        Specified by:
        shutdown in interface IDatabase
      • 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