public class

PrettyPrintWriter

extends AbstractXmlWriter
java.lang.Object
   ↳ com.thoughtworks.xstream.io.xml.AbstractXmlWriter
     ↳ com.thoughtworks.xstream.io.xml.PrettyPrintWriter
Known Direct Subclasses

Class Overview

A simple writer that outputs XML in a pretty-printed indented stream.

By default, the chars

 & < > " ' \r
 
are escaped and replaced with a suitable XML entity. To alter this behavior, override the the writeText(com.thoughtworks.xstream.core.util.QuickWriter, String) and writeAttributeValue(com.thoughtworks.xstream.core.util.QuickWriter, String) methods.

Note: Depending on the XML version some characters cannot be written. Especially a 0 character is never valid in XML, neither directly nor as entity nor within CDATA. However, this writer works by default in a quirks mode, where it will write any character at least as character entity (even a null character). You may switch into XML_1_1 mode (which supports most characters) or XML_1_0 that does only support a very limited number of control characters. See XML specification for version 1.0 or 1.1. If a character is not supported, a StreamException is thrown. Select a proper parser implementation that respects the version in the XML header (the Xpp3 parser will also read character entities of normally invalid characters).

Summary

Fields
public static int XML_1_0
public static int XML_1_1
public static int XML_QUIRKS
protected int depth
Public Constructors
PrettyPrintWriter(Writer writer, char[] lineIndenter, String newLine, XmlFriendlyReplacer replacer)
This constructor is deprecated. since 1.3
PrettyPrintWriter(Writer writer, int mode, char[] lineIndenter, XmlFriendlyReplacer replacer)
PrettyPrintWriter(Writer writer, char[] lineIndenter, String newLine)
This constructor is deprecated. since 1.3
PrettyPrintWriter(Writer writer, int mode, char[] lineIndenter)
PrettyPrintWriter(Writer writer, char[] lineIndenter)
PrettyPrintWriter(Writer writer, String lineIndenter, String newLine)
This constructor is deprecated. since 1.3
PrettyPrintWriter(Writer writer, int mode, String lineIndenter)
PrettyPrintWriter(Writer writer, String lineIndenter)
PrettyPrintWriter(Writer writer, int mode, XmlFriendlyReplacer replacer)
PrettyPrintWriter(Writer writer, XmlFriendlyReplacer replacer)
PrettyPrintWriter(Writer writer, int mode)
PrettyPrintWriter(Writer writer)
Public Methods
void addAttribute(String key, String value)
void close()
void endNode()
void flush()
void setValue(String text)
void startNode(String name, Class clazz)
void startNode(String name)
Protected Methods
void endOfLine()
String getNewLine()
void writeAttributeValue(QuickWriter writer, String text)
void writeText(QuickWriter writer, String text)
[Expand]
Inherited Methods
From class com.thoughtworks.xstream.io.xml.AbstractXmlWriter
From class java.lang.Object
From interface com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriter
From interface com.thoughtworks.xstream.io.HierarchicalStreamWriter
From interface com.thoughtworks.xstream.io.xml.XmlFriendlyWriter

Fields

public static int XML_1_0

public static int XML_1_1

public static int XML_QUIRKS

protected int depth

Public Constructors

public PrettyPrintWriter (Writer writer, char[] lineIndenter, String newLine, XmlFriendlyReplacer replacer)

This constructor is deprecated.
since 1.3

public PrettyPrintWriter (Writer writer, int mode, char[] lineIndenter, XmlFriendlyReplacer replacer)

public PrettyPrintWriter (Writer writer, char[] lineIndenter, String newLine)

This constructor is deprecated.
since 1.3

public PrettyPrintWriter (Writer writer, int mode, char[] lineIndenter)

public PrettyPrintWriter (Writer writer, char[] lineIndenter)

public PrettyPrintWriter (Writer writer, String lineIndenter, String newLine)

This constructor is deprecated.
since 1.3

public PrettyPrintWriter (Writer writer, int mode, String lineIndenter)

public PrettyPrintWriter (Writer writer, String lineIndenter)

public PrettyPrintWriter (Writer writer, int mode, XmlFriendlyReplacer replacer)

public PrettyPrintWriter (Writer writer, XmlFriendlyReplacer replacer)

public PrettyPrintWriter (Writer writer, int mode)

public PrettyPrintWriter (Writer writer)

Public Methods

public void addAttribute (String key, String value)

public void close ()

public void endNode ()

public void flush ()

public void setValue (String text)

public void startNode (String name, Class clazz)

public void startNode (String name)

Protected Methods

protected void endOfLine ()

protected String getNewLine ()

protected void writeAttributeValue (QuickWriter writer, String text)

protected void writeText (QuickWriter writer, String text)