net.aerith.misao.database
Class XmlDBFileAccessor

java.lang.Object
  |
  +--net.aerith.misao.database.XmlDBFileAccessor

public class XmlDBFileAccessor
extends java.lang.Object
implements XmlDBAccessor

The XmlDBFileAccessor represents a sequential accessor to the elements in the primitive database. It keeps the current position in the database.


Field Summary
protected  int index_file
          The index in the file list.
protected  int index_record
          The index in the current XML document.
protected  PrimitiveFileManager manager
          The primitive database manager.
protected  java.io.File[] xml_files
          The list of XML files.
protected  XmlDBRecord[] xml_records
          The records in the current XML document.
 
Constructor Summary
XmlDBFileAccessor(PrimitiveFileManager manager)
          Constructs a XmlDBFileAccessor of the specified database.
 
Method Summary
 java.io.File getCurrentFile()
          Gets the file which contains the current element.
 XmlDBRecord getFirstElement()
          Gets the first element in the database.
 java.io.File getNewFile()
          Gets the new file.
 XmlDBRecord getNextElement()
          Gets the next element in the database.
 java.io.File getVacantFile()
          Gets the file which has room to add the XML element.
 void initialize()
          Initializes.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

manager

protected PrimitiveFileManager manager
The primitive database manager.

xml_files

protected java.io.File[] xml_files
The list of XML files.

index_file

protected int index_file
The index in the file list.

xml_records

protected XmlDBRecord[] xml_records
The records in the current XML document.

index_record

protected int index_record
The index in the current XML document.
Constructor Detail

XmlDBFileAccessor

public XmlDBFileAccessor(PrimitiveFileManager manager)
Constructs a XmlDBFileAccessor of the specified database.
Parameters:
manager - the primitive database manager.
Method Detail

initialize

public void initialize()
Initializes. Lists up all XML files in the database folder.

getVacantFile

public java.io.File getVacantFile()
                           throws java.io.IOException
Gets the file which has room to add the XML element.
Returns:
the file which has room to add the XML element.
Throws:
java.io.IOException - if I/O error occurs.

getNewFile

public java.io.File getNewFile()
                        throws java.io.IOException
Gets the new file.
Returns:
the new file.
Throws:
java.io.IOException - if I/O error occurs.

getCurrentFile

public java.io.File getCurrentFile()
Gets the file which contains the current element.
Returns:
the file which contains the current element.

getFirstElement

public XmlDBRecord getFirstElement()
                            throws java.io.IOException
Gets the first element in the database.
Specified by:
getFirstElement in interface XmlDBAccessor
Returns:
the XML element.
Throws:
java.io.IOException - if I/O error occurs.

getNextElement

public XmlDBRecord getNextElement()
                           throws java.io.IOException
Gets the next element in the database.
Specified by:
getNextElement in interface XmlDBAccessor
Returns:
the XML element.
Throws:
java.io.IOException - if I/O error occurs.