org.marre.xml
Class TextXmlWriter

java.lang.Object
  extended byorg.marre.xml.TextXmlWriter
All Implemented Interfaces:
XmlWriter

public class TextXmlWriter
extends java.lang.Object
implements XmlWriter

XmlWriter that creates text xml documents. NOTE! Not completed yet.

Version:
$Id: TextXmlWriter.java,v 1.2 2004/12/07 20:03:21 c95men Exp $
Author:
Markus Eriksson

Field Summary
protected  boolean myCharsAddedBetweenTags
          Used by addElement to insert a \r\n.
protected  java.util.Stack myTagStack
          Stack of tags.
protected  java.io.Writer myWriter
          The writer that is used internally to store the xml document.
 
Constructor Summary
TextXmlWriter(java.io.Writer writer)
          Constructor.
 
Method Summary
 void addCharacters(char[] ch, int start, int length)
          Adds characters to the xml document.
 void addCharacters(java.lang.String str)
          Adds a string to the xml document.
 void addEmptyElement(java.lang.String tag)
          Adds an empty start element tag.
 void addEmptyElement(java.lang.String tag, XmlAttribute[] attribs)
          Adds an empty start element tag with attributes.
 void addEndElement()
          Adds an end tag.
 void addStartElement(java.lang.String tag)
          Adds a start element tag.
 void addStartElement(java.lang.String tag, XmlAttribute[] attribs)
          Adds a start element tag.
 void flush()
          Flushes the writer.
 void setDoctype(java.lang.String publicID)
          Sets the doctype.
 void setDoctype(java.lang.String name, java.lang.String systemURI)
          Sets the doctype.
 void setDoctype(java.lang.String name, java.lang.String publicID, java.lang.String publicURI)
          Sets the doctype.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myWriter

protected java.io.Writer myWriter
The writer that is used internally to store the xml document.


myTagStack

protected java.util.Stack myTagStack
Stack of tags. Used by addEndElement to know what tag to add.


myCharsAddedBetweenTags

protected boolean myCharsAddedBetweenTags
Used by addElement to insert a \r\n.

Constructor Detail

TextXmlWriter

public TextXmlWriter(java.io.Writer writer)
Constructor.

Parameters:
writer - The writer to write to.
Method Detail

setDoctype

public void setDoctype(java.lang.String publicID)
Sets the doctype.

Specified by:
setDoctype in interface XmlWriter
Parameters:
publicID - XML public ID
See Also:
XmlWriter.setDoctype(java.lang.String)

setDoctype

public void setDoctype(java.lang.String name,
                       java.lang.String systemURI)
Sets the doctype.

Specified by:
setDoctype in interface XmlWriter
Parameters:
name - Name
systemURI - System URI
See Also:
XmlWriter.setDoctype(java.lang.String, java.lang.String)

setDoctype

public void setDoctype(java.lang.String name,
                       java.lang.String publicID,
                       java.lang.String publicURI)
Sets the doctype.

Specified by:
setDoctype in interface XmlWriter
Parameters:
name - Name
publicID - PublicID
publicURI - PublicURI
See Also:
XmlWriter.setDoctype(java.lang.String, java.lang.String, java.lang.String)

addStartElement

public void addStartElement(java.lang.String tag)
                     throws java.io.IOException
Adds a start element tag.

Specified by:
addStartElement in interface XmlWriter
Parameters:
tag - tag
Throws:
java.io.IOException - io error
See Also:
XmlWriter.addStartElement(java.lang.String)

addStartElement

public void addStartElement(java.lang.String tag,
                            XmlAttribute[] attribs)
                     throws java.io.IOException
Adds a start element tag.

Specified by:
addStartElement in interface XmlWriter
Parameters:
tag - Tag
attribs - Attributes
Throws:
java.io.IOException - io error
See Also:
XmlWriter.addStartElement(java.lang.String, org.marre.xml.XmlAttribute[])

addEmptyElement

public void addEmptyElement(java.lang.String tag)
                     throws java.io.IOException
Adds an empty start element tag.

Specified by:
addEmptyElement in interface XmlWriter
Parameters:
tag - Tag
Throws:
java.io.IOException - io error
See Also:
XmlWriter.addEmptyElement(java.lang.String)

addEmptyElement

public void addEmptyElement(java.lang.String tag,
                            XmlAttribute[] attribs)
                     throws java.io.IOException
Adds an empty start element tag with attributes.

Specified by:
addEmptyElement in interface XmlWriter
Parameters:
tag - Tag
attribs - Attributes
Throws:
java.io.IOException - io error
See Also:
XmlWriter.addEmptyElement(java.lang.String, org.marre.xml.XmlAttribute[])

addEndElement

public void addEndElement()
                   throws java.io.IOException
Adds an end tag.

Specified by:
addEndElement in interface XmlWriter
Throws:
java.io.IOException - io error
See Also:
XmlWriter.addEndElement()

addCharacters

public void addCharacters(char[] ch,
                          int start,
                          int length)
                   throws java.io.IOException
Adds characters to the xml document.

Specified by:
addCharacters in interface XmlWriter
Parameters:
ch - The chars to add
start - Start offset of the ch array.
length - Number of chars to add
Throws:
java.io.IOException - io error
See Also:
XmlWriter.addCharacters(char[], int, int)

addCharacters

public void addCharacters(java.lang.String str)
                   throws java.io.IOException
Adds a string to the xml document.

Specified by:
addCharacters in interface XmlWriter
Parameters:
str - Text to add
Throws:
java.io.IOException - io error
See Also:
XmlWriter.addCharacters(java.lang.String)

flush

public void flush()
           throws java.io.IOException
Flushes the writer.

Specified by:
flush in interface XmlWriter
Throws:
java.io.IOException - io error
See Also:
XmlWriter.flush()


Copyright © 2002-2005 Markus Eriksson. All Rights Reserved.