com.generationjava.io.xml
Class PrettyPrinterXmlWriter

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

public class PrettyPrinterXmlWriter
extends DelegatingXmlWriter


Constructor Summary
PrettyPrinterXmlWriter(XmlWriter xmlWriter)
          Create an PrettyPrinterXmlWriter on top of an existing XmlWriter.
 
Method Summary
 XmlWriter endEntity()
          End the current entity.
 XmlWriter setIndent(java.lang.String indent)
          Specify the string to prepend to a line for each level of indent.
 XmlWriter setNewline(java.lang.String newline)
          Specify the string used to terminate each line when pretty printing.
 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()
          Makes it easy to output the xml version if such a thing is desired.
 XmlWriter writeXmlVersion(java.lang.String version, java.lang.String encoding)
           
 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.DelegatingXmlWriter
close, getWriter, writeAttribute, writeEmptyEntity, writeEntityWithText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrettyPrinterXmlWriter

public PrettyPrinterXmlWriter(XmlWriter xmlWriter)
Create an PrettyPrinterXmlWriter on top of an existing XmlWriter.

Method Detail

setIndent

public XmlWriter setIndent(java.lang.String indent)
Specify the string to prepend to a line for each level of indent. It is 2 spaces (" ") by default. Some may prefer a single tab ("\t") or a different number of spaces. Specifying an empty string will turn off indentation when pretty printing.


setNewline

public XmlWriter setNewline(java.lang.String newline)
Specify the string used to terminate each line when pretty printing. It is a single newline ("\n") by default. Users who need to read generated XML documents in Windows editors like Notepad may wish to set this to a carriage return/newline sequence ("\r\n"). Specifying an empty string will turn off generation of line breaks when pretty printing.


writeXmlVersion

public XmlWriter writeXmlVersion()
                          throws java.io.IOException
Description copied from class: DelegatingXmlWriter
Makes it easy to output the xml version if such a thing is desired. While it usually is desired, it is less surprising not to handle it.

Specified by:
writeXmlVersion in interface XmlWriter
Overrides:
writeXmlVersion in class DelegatingXmlWriter
java.io.IOException

writeXmlVersion

public XmlWriter writeXmlVersion(java.lang.String version,
                                 java.lang.String encoding)
                          throws java.io.IOException
Specified by:
writeXmlVersion in interface XmlWriter
Overrides:
writeXmlVersion in class DelegatingXmlWriter
java.io.IOException
See Also:
DelegatingXmlWriter.writeXmlVersion(String, String, String)

writeXmlVersion

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

Specified by:
writeXmlVersion in interface XmlWriter
Overrides:
writeXmlVersion in class DelegatingXmlWriter
java.io.IOException

writeEntity

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

Specified by:
writeEntity in interface XmlWriter
Overrides:
writeEntity in class DelegatingXmlWriter
Parameters:
name - String name of tag
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.

Specified by:
endEntity in interface XmlWriter
Overrides:
endEntity in class DelegatingXmlWriter
java.io.IOException

writeText

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

Specified by:
writeText in interface XmlWriter
Overrides:
writeText in class DelegatingXmlWriter
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.

Specified by:
writeCData in interface XmlWriter
Overrides:
writeCData in class DelegatingXmlWriter
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.

Specified by:
writeComment in interface XmlWriter
Overrides:
writeComment in class DelegatingXmlWriter
java.io.IOException


Copyright © 2000-2003 GenerationJava. All Rights Reserved.