logist.history
Class XMLWriter

java.lang.Object
  extended by logist.history.XMLWriter

public class XMLWriter
extends java.lang.Object

A simple writer for XML files.


Constructor Summary
XMLWriter(java.io.Writer writer)
          Create an XmlWriter on top of an existing java.io.Writer.
 
Method Summary
 void close()
          Close this writer and its underlying writer
 XMLWriter endTag()
          End the current tag.
static java.lang.String escapeXml(java.lang.String string)
           
 void flush()
           
 XMLWriter writeAttribute(java.lang.String name, java.lang.Object value)
          Write an attribute out for the current tag.
 XMLWriter writeAttribute(java.lang.String name, java.lang.String value)
          Write an attribute out for the current tag.
 XMLWriter writeComment(java.lang.String comment)
          Output a comment.
 XMLWriter writeTag(java.lang.String name)
          Begin to output a tag.
 void writeText(java.lang.Object object)
           
 XMLWriter writeText(java.lang.String text)
          Output body text.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLWriter

public XMLWriter(java.io.Writer writer)
Create an XmlWriter on top of an existing java.io.Writer.

Method Detail

writeTag

public XMLWriter writeTag(java.lang.String name)
Begin to output a tag.

Parameters:
name - the name of the tag.

writeAttribute

public XMLWriter writeAttribute(java.lang.String name,
                                java.lang.String value)
Write an attribute out for the current tag. Any XML characters in the value are escaped.

Parameters:
name - the name of the attribute
value - the value of the attribute

writeAttribute

public XMLWriter writeAttribute(java.lang.String name,
                                java.lang.Object value)
Write an attribute out for the current tag. The value is converted to a string using the toString method. Any XML characters in the value are escaped.

Parameters:
name - the name of the attribute
value - the value of the attribute

endTag

public XMLWriter endTag()
End the current tag.

Throws:
XMLWritingException - if there is no open tag

flush

public void flush()

close

public void close()
Close this writer and its underlying writer

Throws:
XMLWritingException - if there are unclosed tags.

writeText

public XMLWriter writeText(java.lang.String text)
Output body text. Any XML characters are escaped.

Parameters:
text - the text to be written

writeComment

public XMLWriter writeComment(java.lang.String comment)
Output a comment. Any XML characters are escaped.

Parameters:
comment - the text to be written

escapeXml

public static java.lang.String escapeXml(java.lang.String string)
Parameters:
string - the string to be written to an XML file
Returns:
the escaped string

writeText

public void writeText(java.lang.Object object)