com.generationjava.io.xml
Class SimpleXmlWriter

java.lang.Object
  |
  +--com.generationjava.io.xml.AbstractXmlWriter
        |
        +--com.generationjava.io.xml.SimpleXmlWriter
All Implemented Interfaces:
XmlWriter

public class SimpleXmlWriter
extends AbstractXmlWriter

Makes writing XML much much easier. Improved from article

Version:
1.0
Author:
Henri Yandell, Peter Cassetta

Constructor Summary
SimpleXmlWriter(java.io.Writer writer)
          Create an SimpleXmlWriter on top of an existing java.io.Writer.
 
Method Summary
 void close()
          Close this writer.
 XmlWriter endEntity()
          End the current entity.
 java.lang.String getDefaultNamespace()
           
 java.io.Writer getWriter()
          Obtain the Writer that is at the lowest level of this XmlWriter chain
 void setDefaultNamespace(java.lang.String namespace)
          The default namespace.
 XmlWriter writeAttribute(java.lang.String attr, java.lang.Object value)
          Write an attribute out for the current entity.
 XmlWriter writeCData(java.lang.String cdata)
          Write out a chunk of CDATA.
 XmlWriter writeComment(java.lang.String comment)
          Write out a chunk of comment.
 XmlWriter writeEntity(java.lang.String name)
          Begin to write out an entity.
 XmlWriter writeText(java.lang.Object text)
          Output body text.
 XmlWriter writeXmlVersion(java.lang.String version, java.lang.String encoding, java.lang.String standalone)
          Output the version, encoding and standalone nature of an xml file.
 
Methods inherited from class com.generationjava.io.xml.AbstractXmlWriter
writeEmptyEntity, writeEntityWithText, writeXmlVersion, writeXmlVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleXmlWriter

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

Method Detail

setDefaultNamespace

public void setDefaultNamespace(java.lang.String namespace)
The default namespace. Once this is turned on, any new entities will have this namespace, regardless of scope.


getDefaultNamespace

public java.lang.String getDefaultNamespace()

writeXmlVersion

public XmlWriter writeXmlVersion(java.lang.String version,
                                 java.lang.String encoding,
                                 java.lang.String standalone)
                          throws java.io.IOException
Output the version, encoding and standalone nature of an xml file.

java.io.IOException

writeEntity

public XmlWriter writeEntity(java.lang.String name)
                      throws java.io.IOException
Begin to write out an entity. Unlike the helper tags, this tag will need to be ended with the endEntity method.

Parameters:
name - String name of tag
java.io.IOException

writeAttribute

public XmlWriter writeAttribute(java.lang.String attr,
                                java.lang.Object value)
                         throws java.io.IOException
Write an attribute out for the current entity. Any xml characters in the value are escaped. Currently it does not actually throw the exception, but the api is set that way for future changes.

java.io.IOException

endEntity

public XmlWriter endEntity()
                    throws java.io.IOException
End the current entity. This will throw an exception if it is called when there is not a currently open entity.

java.io.IOException

close

public void close()
           throws java.io.IOException
Close this writer. It does not close the underlying writer, but does throw an exception if there are as yet unclosed tags.

java.io.IOException

writeText

public XmlWriter writeText(java.lang.Object text)
                    throws java.io.IOException
Output body text. Any xml characters are escaped.

java.io.IOException

writeCData

public XmlWriter writeCData(java.lang.String cdata)
                     throws java.io.IOException
Write out a chunk of CDATA. This helper method surrounds the passed in data with the CDATA tag.

java.io.IOException

writeComment

public XmlWriter writeComment(java.lang.String comment)
                       throws java.io.IOException
Write out a chunk of comment. This helper method surrounds the passed in data with the xml comment tag.

java.io.IOException

getWriter

public java.io.Writer getWriter()
Description copied from interface: XmlWriter
Obtain the Writer that is at the lowest level of this XmlWriter chain



Copyright © 2000-2003 GenerationJava. All Rights Reserved.