org.jscience.architecture.traffic.xml
Class XMLSaver

java.lang.Object
  extended by org.jscience.architecture.traffic.xml.XMLSaver

public class XMLSaver
extends java.lang.Object

This class takes care of saving the state of the program to a XML file. It also provides methods which XMLSerializable objects can use to save their child objects.


Field Summary
protected  XMLStack stack
          DOCUMENT ME!
protected  org.jscience.architecture.traffic.xml.XMLWriter writer
          DOCUMENT ME!
 
Constructor Summary
protected XMLSaver()
          Make a new XMLSaver
  XMLSaver(java.io.File file)
          Makes a new XMLSaver which saves to a file
  XMLSaver(java.lang.String hostname, int port)
          Makes a new XMLSaver which saves to a socket
 
Method Summary
 void close()
          Close this XMLSaver
 boolean hasStream()
          A crude indication if we can write to this XMLSaver
protected  int indent()
          DOCUMENT ME!
 void saveAtomaryElement(XMLSerializable parent, XMLElement el)
          Save an atomary XML element
 void saveEnumerationObjects(java.util.Enumeration e)
          Save an enumeration of XML Serializables to file
 void saveObject(XMLSerializable object)
          Save a XMLSerializable object to the XML file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

writer

protected org.jscience.architecture.traffic.xml.XMLWriter writer
DOCUMENT ME!


stack

protected XMLStack stack
DOCUMENT ME!

Constructor Detail

XMLSaver

protected XMLSaver()
Make a new XMLSaver


XMLSaver

public XMLSaver(java.io.File file)
         throws java.io.IOException
Makes a new XMLSaver which saves to a file

Parameters:
file - The file to save to
Throws:
java.io.IOException - If the XMLSaver cannot open the XML file because of an IO error.

XMLSaver

public XMLSaver(java.lang.String hostname,
                int port)
         throws java.io.IOException
Makes a new XMLSaver which saves to a socket

Parameters:
hostname - The hostname to connect to
port - The port to connect to
Throws:
java.io.IOException - If the XMLSaver cannot open the socket connection because of an IO error.
Method Detail

hasStream

public boolean hasStream()
A crude indication if we can write to this XMLSaver

Returns:
DOCUMENT ME!

close

public void close()
Close this XMLSaver


saveObject

public void saveObject(XMLSerializable object)
                throws java.io.IOException,
                       XMLTreeException,
                       XMLCannotSaveException
Save a XMLSerializable object to the XML file

Parameters:
object - The object to save
Throws:
java.io.IOException - If the XMLSaver cannot write to the XML file because of an IO error.
XMLTreeException - If something goes wrong while the parser is building the XML tree structure for this object
XMLCannotSaveException - If this object cannot save itself

saveEnumerationObjects

public void saveEnumerationObjects(java.util.Enumeration e)
                            throws java.lang.ClassCastException,
                                   XMLTreeException,
                                   java.io.IOException,
                                   XMLCannotSaveException
Save an enumeration of XML Serializables to file

Parameters:
e - The enumeration of XML Serializables
Throws:
java.lang.ClassCastException - If the enumeration contains an object that is not XMLSerializable
XMLTreeException - If something goes wrong while the parser is building the XML tree structure for one of the objects.
java.io.IOException - If the XMLSaver cannot write to the XML file because of an IO error.
XMLCannotSaveException - If one of the objects cannot save itself for one reason or another.

saveAtomaryElement

public void saveAtomaryElement(XMLSerializable parent,
                               XMLElement el)
                        throws java.io.IOException,
                               XMLTreeException
Save an atomary XML element

Parameters:
parent - DOCUMENT ME!
el - The XMLElement to save
Throws:
java.io.IOException - If the XMLSaver cannot write to the XML file because of an IO error.
XMLTreeException - If there is a parser problem with writing the element.

indent

protected int indent()
DOCUMENT ME!

Returns:
An internal indentation string