org.codehaus.plexus.util.xml

Class PrettyPrintXMLWriter

public class PrettyPrintXMLWriter extends Object implements XMLWriter

Implementation of XMLWriter which emits nicely formatted documents.

Version: $Id: PrettyPrintXMLWriter.java 8660 2010-03-05 21:50:36Z hboutemy $

Field Summary
protected static StringLS
Line separator ("\n" on UNIX)
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)
PrettyPrintXMLWriter(PrintWriter writer, String lineIndenter, String lineSeparator, String encoding, String doctype)
Method Summary
voidaddAttribute(String key, String value)
voidendElement()
protected voidendOfLine()
Write the end of line character (using specified line separator) and start new line with indentation
protected intgetDepth()
Get the current depth in the xml indentation
protected StringgetDocType()
Get the docType in the xml
protected LinkedListgetElementStack()
protected StringgetEncoding()
Get the current encoding in the xml
protected StringgetLineIndenter()
Get the string used as line indenter
protected StringgetLineSeparator()
Get the string used as line separator or LS if not set.
protected PrintWritergetWriter()
Get the underlying writer
protected voidsetDepth(int depth)
Set the depth in the xml indentation
protected voidsetDocType(String docType)
Set the docType in the xml
protected voidsetEncoding(String encoding)
Set the encoding in the xml
protected voidsetLineIndenter(String lineIndenter)
Set the string used as line indenter
protected voidsetLineSeparator(String lineSeparator)
Set the string used as line separator
protected voidsetWriter(PrintWriter writer)
Set the underlying writer
voidstartElement(String name)
voidwriteMarkup(String text)
voidwriteText(String text)

Field Detail

LS

protected static final String LS
Line separator ("\n" on UNIX)

Constructor Detail

PrettyPrintXMLWriter

public PrettyPrintXMLWriter(PrintWriter writer, String lineIndenter)

Parameters: writer not null lineIndenter could be null, but the normal way is some spaces.

PrettyPrintXMLWriter

public PrettyPrintXMLWriter(Writer writer, String lineIndenter)

Parameters: writer not null lineIndenter could be null, but the normal way is some spaces.

PrettyPrintXMLWriter

public PrettyPrintXMLWriter(PrintWriter writer)

Parameters: writer not null

PrettyPrintXMLWriter

public PrettyPrintXMLWriter(Writer writer)

Parameters: writer not null

PrettyPrintXMLWriter

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

Parameters: writer not null lineIndenter could be null, but the normal way is some spaces. encoding could be null or invalid. doctype could be null.

PrettyPrintXMLWriter

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

Parameters: writer not null lineIndenter could be null, but the normal way is some spaces. encoding could be null or invalid. doctype could be null.

PrettyPrintXMLWriter

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

Parameters: writer not null encoding could be null or invalid. doctype could be null.

PrettyPrintXMLWriter

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

Parameters: writer not null encoding could be null or invalid. doctype could be null.

PrettyPrintXMLWriter

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

Parameters: writer not null lineIndenter could be null, but the normal way is some spaces. lineSeparator could be null, but the normal way is valid line separator ("\n" on UNIX). encoding could be null or invalid. doctype could be null.

Method Detail

addAttribute

public void addAttribute(String key, String value)
{@inheritDoc }

endElement

public void endElement()
{@inheritDoc }

endOfLine

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

See Also: getLineIndenter getLineSeparator

getDepth

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

Returns: the current depth

getDocType

protected String getDocType()
Get the docType in the xml

Returns: the current docType

getElementStack

protected LinkedList getElementStack()

Returns: the current elementStack;

getEncoding

protected String getEncoding()
Get the current encoding in the xml

Returns: the current encoding

getLineIndenter

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

Returns: the line indenter

getLineSeparator

protected String getLineSeparator()
Get the string used as line separator or LS if not set.

Returns: the line separator

See Also: LS

getWriter

protected PrintWriter getWriter()
Get the underlying writer

Returns: the underlying writer

setDepth

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

Parameters: depth new depth

setDocType

protected void setDocType(String docType)
Set the docType in the xml

Parameters: docType new docType

setEncoding

protected void setEncoding(String encoding)
Set the encoding in the xml

Parameters: encoding new encoding

setLineIndenter

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

Parameters: lineIndenter new line indenter, could be null, but the normal way is some spaces.

setLineSeparator

protected void setLineSeparator(String lineSeparator)
Set the string used as line separator

Parameters: lineSeparator new line separator, could be null but the normal way is valid line separator ("\n" on UNIX).

setWriter

protected void setWriter(PrintWriter writer)
Set the underlying writer

Parameters: writer not null writer

startElement

public void startElement(String name)
{@inheritDoc }

writeMarkup

public void writeMarkup(String text)
{@inheritDoc }

writeText

public void writeText(String text)
{@inheritDoc }
Copyright © 2001-2010 Codehaus. All Rights Reserved.