Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.thoughtworks.xstream.io.xml
Class PrettyPrintWriter

    java.lang.Object
      com.thoughtworks.xstream.io.xml.AbstractXmlWriter
          com.thoughtworks.xstream.io.xml.PrettyPrintWriter

All Implemented Interfaces:
  ExtendedHierarchicalStreamWriter, HierarchicalStreamWriter, XmlFriendlyWriter

Direct Known Subclasses:
  CompactWriter

    public class PrettyPrintWriter

extends AbstractXmlWriter

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).

Author:
  Joe Walnes, Jörg Schaible

Field Summary
`protected int` | `depth`
`static int` | `XML_1_0`
`static int` | `XML_1_1`
`static int` | `XML_QUIRKS`

Constructor Summary
`PrettyPrintWriter(Writer writer)`
`PrettyPrintWriter(Writer writer, char[] lineIndenter)`
`PrettyPrintWriter(Writer writer, char[] lineIndenter, String newLine)` Deprecated. since 1.3
`PrettyPrintWriter(Writer writer, char[] lineIndenter, String newLine, XmlFriendlyReplacer replacer)` Deprecated. since 1.3
`PrettyPrintWriter(Writer writer, int mode)`
`PrettyPrintWriter(Writer writer, int mode, char[] lineIndenter)`
`PrettyPrintWriter(Writer writer, int mode, char[] lineIndenter, XmlFriendlyReplacer replacer)`
`PrettyPrintWriter(Writer writer, int mode, String lineIndenter)`
`PrettyPrintWriter(Writer writer, int mode, XmlFriendlyReplacer replacer)`
`PrettyPrintWriter(Writer writer, String lineIndenter)`
`PrettyPrintWriter(Writer writer, String lineIndenter, String newLine)` Deprecated. since 1.3
`PrettyPrintWriter(Writer writer, XmlFriendlyReplacer replacer)`

Method Summary
`void` | `addAttribute(String key, String value)`
`void` | `close()` Close the writer, if necessary.
`void` | `endNode()`
`protected void` | `endOfLine()`
`void` | `flush()` Flush the writer, if necessary.
`protected String` | `getNewLine()`
`void` | `setValue(String text)` Write the value (text content) of the current node.
`void` | `startNode(String name)`
`void` | `startNode(String name, Class clazz)`
`protected void` | `writeAttributeValue(com.thoughtworks.xstream.core.util.QuickWriter writer, String text)`
`protected void` | `writeText(com.thoughtworks.xstream.core.util.QuickWriter writer, String text)`

Methods inherited from class com.thoughtworks.xstream.io.xml.AbstractXmlWriter
`escapeXmlName, underlyingWriter`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### XML_QUIRKS

    public static int XML_QUIRKS

### XML_1_0

    public static int XML_1_0

### XML_1_1

    public static int XML_1_1

### depth

    protected int depth

Constructor Detail

### PrettyPrintWriter

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

  Deprecated. since 1.3

  Since:
    1.2

### PrettyPrintWriter

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

Since:
  1.3

### PrettyPrintWriter

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

  Deprecated. since 1.3

### PrettyPrintWriter

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

Since:
  1.3

### PrettyPrintWriter

    public PrettyPrintWriter(Writer writer,
                             char[] lineIndenter)

### PrettyPrintWriter

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

  Deprecated. since 1.3

### PrettyPrintWriter

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

Since:
  1.3

### PrettyPrintWriter

    public PrettyPrintWriter(Writer writer,
                             String lineIndenter)

### PrettyPrintWriter

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

Since:
  1.3

### PrettyPrintWriter

    public PrettyPrintWriter(Writer writer,
                             XmlFriendlyReplacer replacer)

### PrettyPrintWriter

    public PrettyPrintWriter(Writer writer,
                             int mode)

Since:
  1.3

### PrettyPrintWriter

    public PrettyPrintWriter(Writer writer)

Method Detail

### startNode

    public void startNode(String name)

### startNode

    public void startNode(String name,
                          Class clazz)

  Specified by:
    `startNode` in interface `ExtendedHierarchicalStreamWriter`
  Overrides:
    `startNode` in class `AbstractXmlWriter`

### setValue

    public void setValue(String text)

  Description copied from interface: `HierarchicalStreamWriter`
  Write the value (text content) of the current node.

### addAttribute

    public void addAttribute(String key,
                             String value)

### writeAttributeValue

    protected void writeAttributeValue(com.thoughtworks.xstream.core.util.QuickWriter writer,
                                       String text)

### writeText

    protected void writeText(com.thoughtworks.xstream.core.util.QuickWriter writer,
                             String text)

### endNode

    public void endNode()

### endOfLine

    protected void endOfLine()

### flush

    public void flush()

  Description copied from interface: `HierarchicalStreamWriter`
  Flush the writer, if necessary.

### close

    public void close()

  Description copied from interface: `HierarchicalStreamWriter`
  Close the writer, if necessary.

### getNewLine

    protected String getNewLine()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004-2008 XStream. All Rights Reserved.