org.codehaus.plexus.util.xml

Class PrettyPrintXMLWriter

public class PrettyPrintXMLWriter extends Object implements XMLWriter

Version: $Id: PrettyPrintXMLWriter.java 5958 2007-02-28 10:29:55Z olamy $

Field Summary
intdepth
StringdocType
LinkedListelementStack
Stringencoding
StringlineIndenter
static StringLS
booleanreadyForNewLine
booleantagInProgress
booleantagIsEmpty
PrintWriterwriter
Constructor Summary
PrettyPrintXMLWriter(PrintWriter writer, String lineIndenter)
PrettyPrintXMLWriter(Writer writer, String lineIndenter)
PrettyPrintXMLWriter(PrintWriter writer)
PrettyPrintXMLWriter(Writer writer)
PrettyPrintXMLWriter(PrintWriter writer, String lineIndenter, String encoding, String doctype)
PrettyPrintXMLWriter(Writer writer, String lineIndenter, String encoding, String doctype)
PrettyPrintXMLWriter(PrintWriter writer, String encoding, String doctype)
PrettyPrintXMLWriter(Writer writer, String encoding, String doctype)
Method Summary
voidaddAttribute(String key, String value)
voidendElement()
protected voidendOfLine()
Write the end of line character (using system line separator) and start new line with indentation
static StringescapeXml(String text)
static StringescapeXmlAttribute(String text)
voidfinishTag()
protected intgetDepth()
Get the current depth in the xml indentation
protected StringgetDocType()
protected StringgetEncoding()
protected StringgetLineIndenter()
Get the string used as line indenter
protected PrintWritergetWriter()
Get the underlying writer
protected voidsetDepth(int depth)
Set the current depth in the xml indentation
protected voidsetDocType(String docType)
protected voidsetEncoding(String encoding)
protected voidsetLineIndenter(String lineIndenter)
Set the string used as line indenter
protected voidsetWriter(PrintWriter writer)
Set the underlying writer
voidstartElement(String name)
voidwrite(String str)
Write a string to the underlying writer
voidwriteDocumentHeaders()
voidwriteMarkup(String text)
voidwriteText(String text)
voidwriteText(String text, boolean escapeXml)

Field Detail

depth

private int depth

docType

private String docType

elementStack

private LinkedList elementStack

encoding

private String encoding

lineIndenter

private String lineIndenter

LS

private static final String LS

readyForNewLine

private boolean readyForNewLine

tagInProgress

private boolean tagInProgress

tagIsEmpty

private boolean tagIsEmpty

writer

private PrintWriter writer

Constructor Detail

PrettyPrintXMLWriter

public PrettyPrintXMLWriter(PrintWriter writer, String lineIndenter)

PrettyPrintXMLWriter

public PrettyPrintXMLWriter(Writer writer, String lineIndenter)

PrettyPrintXMLWriter

public PrettyPrintXMLWriter(PrintWriter writer)

PrettyPrintXMLWriter

public PrettyPrintXMLWriter(Writer writer)

PrettyPrintXMLWriter

public PrettyPrintXMLWriter(PrintWriter writer, String lineIndenter, String encoding, String doctype)

PrettyPrintXMLWriter

public PrettyPrintXMLWriter(Writer writer, String lineIndenter, String encoding, String doctype)

PrettyPrintXMLWriter

public PrettyPrintXMLWriter(PrintWriter writer, String encoding, String doctype)

PrettyPrintXMLWriter

public PrettyPrintXMLWriter(Writer writer, String encoding, String doctype)

Method Detail

addAttribute

public void addAttribute(String key, String value)

endElement

public void endElement()

endOfLine

protected void endOfLine()
Write the end of line character (using system line separator) and start new line with indentation

escapeXml

private static String escapeXml(String text)

escapeXmlAttribute

private static String escapeXmlAttribute(String text)

finishTag

private void finishTag()

getDepth

protected int getDepth()
Get the current depth in the xml indentation

Returns:

getDocType

protected String getDocType()

getEncoding

protected String getEncoding()

getLineIndenter

protected String getLineIndenter()
Get the string used as line indenter

Returns: the line indenter

getWriter

protected PrintWriter getWriter()
Get the underlying writer

Returns: the underlying writer

setDepth

protected void setDepth(int depth)
Set the current depth in the xml indentation

Parameters: depth

setDocType

protected void setDocType(String docType)

setEncoding

protected void setEncoding(String encoding)

setLineIndenter

protected void setLineIndenter(String lineIndenter)
Set the string used as line indenter

Parameters: lineIndenter

setWriter

protected void setWriter(PrintWriter writer)
Set the underlying writer

Parameters: writer

startElement

public void startElement(String name)

write

private void write(String str)
Write a string to the underlying writer

Parameters: str

writeDocumentHeaders

private void writeDocumentHeaders()

writeMarkup

public void writeMarkup(String text)

writeText

public void writeText(String text)

writeText

private void writeText(String text, boolean escapeXml)