tribble.xml.impl
Class XmlWriter

java.lang.Object
  extended bytribble.xml.impl.XmlWriter
All Implemented Interfaces:
XmlWriterI

public class XmlWriter
extends java.lang.Object
implements XmlWriterI

XML document writer, default implementation.

Since:
2003-07-11
Version:
$Revision: 1.2 $ $Date: 2003/08/10 21:21:45 $
Author:
David R. Tribble (david@tribble.com).
Copyright 2003 by David R. Tribble, all rights reserved.
See Also:
XmlReader

Field Summary
protected  char m_lastCh
          Last character written to the underlying output stream.
protected  java.io.BufferedWriter m_out
          Underlying output stream.
 
Constructor Summary
XmlWriter(java.io.OutputStream out)
          Constructor.
XmlWriter(java.io.Writer out)
          Constructor.
 
Method Summary
 void writeAttribute(XmlAttributeI ent)
          Write an XML element attribute to this XML output stream.
 void writeComment(java.lang.String text)
          Write a comment to this XML output stream.
 void writeElement(XmlElementI ent)
          Write an XML tagged element to this XML output stream.
 void writeText(java.lang.String text)
          Write the text contents of the current XML element to this XML output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_out

protected java.io.BufferedWriter m_out
Underlying output stream.


m_lastCh

protected char m_lastCh
Last character written to the underlying output stream.

Constructor Detail

XmlWriter

public XmlWriter(java.io.Writer out)
Constructor.

Parameters:
out - Underlying output stream. It is assumed that this stream writes character data in UTF-8 encoding.

For efficiency, this is internally wrapped with a java.io.BufferedWriter, unless it is already such an object.

Since:
1.1, 2003-07-16

XmlWriter

public XmlWriter(java.io.OutputStream out)
Constructor.

Parameters:
out - Underlying output stream. Characters are written to this stream in UTF-8 encoding.
Since:
1.1, 2003-07-16
Method Detail

writeElement

public void writeElement(XmlElementI ent)
                  throws java.io.IOException
Write an XML tagged element to this XML output stream.

Specified by:
writeElement in interface XmlWriterI
Parameters:
ent - An XML tagged element.
Throws:
java.io.IOException - Thrown if an I/O (write) error occurs.
java.lang.IllegalStateException - (unchecked) Thrown if this writer is not in the proper state for writing.
Since:
1.1, 2003-04-13

writeAttribute

public void writeAttribute(XmlAttributeI ent)
                    throws java.io.IOException
Write an XML element attribute to this XML output stream.

Specified by:
writeAttribute in interface XmlWriterI
Parameters:
ent - An XML element attribute.
Throws:
java.io.IOException - Thrown if an I/O (write) error occurs.
java.lang.IllegalStateException - (unchecked) Thrown if this writer is not in the proper state for writing.
Since:
1.1, 2003-04-13

writeText

public void writeText(java.lang.String text)
               throws java.io.IOException
Write the text contents of the current XML element to this XML output stream.

Specified by:
writeText in interface XmlWriterI
Parameters:
text - Text contents of the current XML element.
Throws:
java.io.IOException - Thrown if an I/O (write) error occurs.
java.lang.IllegalStateException - (unchecked) Thrown if this writer is not in the proper state for writing.
Since:
1.1, 2003-04-13

writeComment

public void writeComment(java.lang.String text)
                  throws java.io.IOException
Write a comment to this XML output stream.

Specified by:
writeComment in interface XmlWriterI
Parameters:
text - Comment text.
Throws:
java.io.IOException - Thrown if an I/O (write) error occurs.
java.lang.IllegalStateException - (unchecked) Thrown if this writer is not in the proper state for writing.
Since:
1.2, 2003-04-15