com.chaosserver.bilbo.data
Class DataReaderWriter

java.lang.Object
  |
  +--com.chaosserver.bilbo.data.DataReaderWriter

public class DataReaderWriter
extends Object

Responsible for persistence of the Directory structure to/from an Xml mapping file.

Since:
Bilbo 1.0

Field Summary
static String DIRECTORY_TAG
          Xml tag for the Directory object.
protected  Document document
          Holds teh document being constructed for writing.
static String FILE_TAG
          Xml tag for the FileMapping object.
static String NAME_TAG
          Xml tag for the Name object.
static String STYLE_ATT
          Xml attribute for the style property of the name attribute.
 
Constructor Summary
DataReaderWriter()
          Default constructor.
 
Method Summary
protected  void addFilenameMapping(Node node, FilenameMapping filenameMapping)
          Generates a new node for the FilenameMapping and appends it the node passed in.
protected  void addName(Node node, Name name)
          Generates a new node the Name and appends it to the node passed in.
 Directory read(Reader reader)
          Reads in a Xml version of a directory and demarshalls it into the object.
 void write(Writer writer, Directory directory)
          Writes the Directory object as Xml to the given writier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIRECTORY_TAG

public static final String DIRECTORY_TAG
Xml tag for the Directory object.

See Also:
Constant Field Values

FILE_TAG

public static final String FILE_TAG
Xml tag for the FileMapping object.

See Also:
Constant Field Values

NAME_TAG

public static final String NAME_TAG
Xml tag for the Name object.

See Also:
Constant Field Values

STYLE_ATT

public static final String STYLE_ATT
Xml attribute for the style property of the name attribute.

See Also:
Constant Field Values

document

protected Document document
Holds teh document being constructed for writing. This is needed for the creation of nodes on the document.

Constructor Detail

DataReaderWriter

public DataReaderWriter()
Default constructor.

Method Detail

write

public void write(Writer writer,
                  Directory directory)
           throws ReaderWriterException
Writes the Directory object as Xml to the given writier.

Parameters:
writer - the writer to put the xml output into
directory - the directory to convert to xml and write
Throws:
ReaderWriterException - if there is an error

addFilenameMapping

protected void addFilenameMapping(Node node,
                                  FilenameMapping filenameMapping)
                           throws ReaderWriterException
Generates a new node for the FilenameMapping and appends it the node passed in.

Parameters:
node - the node to append to
filenameMapping - the filenameMapping to convert to a node
Throws:
ReaderWriterException - if something goes wrong

addName

protected void addName(Node node,
                       Name name)
                throws ReaderWriterException
Generates a new node the Name and appends it to the node passed in.

Parameters:
node - the node to append to
name - the name to convert to a node
ReaderWriterException

read

public Directory read(Reader reader)
               throws ReaderWriterException
Reads in a Xml version of a directory and demarshalls it into the object.

Parameters:
reader - the reader that the Xml comes from
Returns:
the Directory represented by the Xml
Throws:
ReaderWriterException - if something goes wrong.


Copyright © 20020226