net.aerith.misao.database
Class PrimitiveManager

java.lang.Object
  |
  +--net.aerith.misao.database.PrimitiveManager
Direct Known Subclasses:
PrimitiveFileManager, PrimitiveMemoryManager

public abstract class PrimitiveManager
extends java.lang.Object

The PrimitiveManager is an abstract class of a database manager which covers one virtual folder containing XML elements of the same type.


Field Summary
protected  XmlDBHolder holder_class
          The holder class object of the XML records.
protected  XmlDBRecord record_class
          The class of the XML records.
 
Constructor Summary
PrimitiveManager()
           
 
Method Summary
abstract  void addElement(XmlDBRecord element)
          Adds the specified XML element into the database.
abstract  void addElements(java.util.Vector list)
          Adds the XML elements in the specified list into the database.
 XmlDBHolder createHolder()
          Creates an empty holder object.
abstract  XmlDBRecord deleteElement(java.lang.String id)
          Deletes the element of the specified ID.
abstract  void deleteElements(java.util.Hashtable hash)
          Deletes the elements in the specified hash table.
abstract  XmlDBAccessor getAccessor()
          Gets the sequential accessor to the elements in the database.
 XmlDBRecord getElement(java.lang.String id)
          Gets the element of the specified ID.
abstract  XmlDBRecord setElement(XmlDBRecord element)
          Adds or updates the specified XML element into the database.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

holder_class

protected XmlDBHolder holder_class
The holder class object of the XML records.

record_class

protected XmlDBRecord record_class
The class of the XML records.
Constructor Detail

PrimitiveManager

public PrimitiveManager()
Method Detail

createHolder

public XmlDBHolder createHolder()
Creates an empty holder object.
Returns:
an empty holder object.

getElement

public XmlDBRecord getElement(java.lang.String id)
                       throws java.io.IOException
Gets the element of the specified ID.
Parameters:
id - the ID.
Returns:
the XML element.
Throws:
java.io.IOException - if I/O error occurs.

addElement

public abstract void addElement(XmlDBRecord element)
                         throws java.io.IOException
Adds the specified XML element into the database.
Parameters:
element - the XML element.
Throws:
java.io.IOException - if I/O error occurs.

addElements

public abstract void addElements(java.util.Vector list)
                          throws java.io.IOException
Adds the XML elements in the specified list into the database. All elements in the list are saved in one new XML file. Because the total file size is uncertain, the limitation of the size of an XML file does not work when using this method.
Parameters:
list - the list of XML elements.
Throws:
java.io.IOException - if I/O error occurs.

setElement

public abstract XmlDBRecord setElement(XmlDBRecord element)
                                throws java.io.IOException
Adds or updates the specified XML element into the database. It checks if the element whose ID is the same as the specified element already exists or not. When it does, the data is updated. Otherwise, the element is newly added.
Parameters:
element - the XML element.
Returns:
the old XML element if the element of the specified ID already exists, or null.
Throws:
java.io.IOException - if I/O error occurs.

deleteElement

public abstract XmlDBRecord deleteElement(java.lang.String id)
                                   throws java.io.IOException
Deletes the element of the specified ID.
Parameters:
id - the ID.
Returns:
the deleted XML element, or null if the element of the specified ID does not exist.
Throws:
java.io.IOException - if I/O error occurs.

deleteElements

public abstract void deleteElements(java.util.Hashtable hash)
                             throws java.io.IOException
Deletes the elements in the specified hash table. After the operation, some of the elements in the specified hash table are deleted, which are in this database. Others are remained. The IDs of the deleted elements are also deleted from the hash table.
Parameters:
hash - the hash table whose keys are IDs of the elements to be deleted.
Throws:
java.io.IOException - if I/O error occurs.

getAccessor

public abstract XmlDBAccessor getAccessor()
Gets the sequential accessor to the elements in the database.
Returns:
the sequential accessor.