Deprecated
as a consequence of AbstractXmlWriter being deprecated. See corresponding docs for further information.
By default, the chars & < > " ' \r
are escaped
and replaced with a suitable XML entity. To alter this behavior, override
the writeText(com. and
writeAttributeValue(com. methods.
The XML specification requires XML parsers to drop CR characters completely. This implementation
will therefore use only a LF for line endings, never the platform encoding. You can overwrite the
getNewLine() method for a different behavior.
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).
| Modifier and Type | Field and Description |
|---|---|
| private static final char[] | |
| private static final char[] | |
| private static final char[] | |
| private static final char[] | |
| protected int | |
| private final FastStack | |
| private static final char[] | |
| private final char[] | |
| private static final char[] | |
| private final int | |
| private String | |
| private static final char[] | |
| private static final char[] | |
| private boolean | |
| private boolean | |
| private boolean | |
| private final QuickWriter | |
| public static int | |
| public static int | |
| public static int |
| Access | Constructor and Description |
|---|---|
| private | PrettyPrintWriter(Writer writer, int mode, char[] lineIndenter, NameCoder nameCoder, String newLine)
|
| public | PrettyPrintWriter(Writer writer, char[] lineIndenter, String newLine, XmlFriendlyReplacer replacer)
Deprecated
As of 1.3
|
| public | |
| public | PrettyPrintWriter(Writer writer, int mode, char[] lineIndenter, XmlFriendlyReplacer replacer)
Deprecated
As of 1.4 use
PrettyPrintWriter#PrettyPrintWriter(Writer, int, char[], NameCoder) instead
|
| public | |
| public | |
| public | |
| public | |
| public | |
| public | |
| public | |
| public | PrettyPrintWriter(Writer writer, int mode, XmlFriendlyReplacer replacer)
Deprecated
As of 1.4 use
PrettyPrintWriter#PrettyPrintWriter(Writer, int, NameCoder) instead
|
| public | |
| public | PrettyPrintWriter(Writer writer, XmlFriendlyReplacer replacer)
Deprecated
As of 1.4 use
PrettyPrintWriter#PrettyPrintWriter(Writer, NameCoder) instead.
|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | addAttribute(String key, String value)
Implements com. |
| public void | close()
Implements com. |
| public void | |
| protected void | |
| private void | |
| public void | flush()
Implements com. |
| protected String | |
| public void | setValue(String text)
Implements com. |
| public void | |
| public void | startNode(String name, Class<T> clazz)
Overrides com. Implements com. |
| protected void | |
| protected void | |
| private void |
| AMP | back to summary |
|---|---|
| private static final char[] AMP | |
| APOS | back to summary |
|---|---|
| private static final char[] APOS | |
| CLOSE | back to summary |
|---|---|
| private static final char[] CLOSE | |
| CR | back to summary |
|---|---|
| private static final char[] CR | |
| depth | back to summary |
|---|---|
| protected int depth | |
| elementStack | back to summary |
|---|---|
| private final FastStack elementStack | |
| GT | back to summary |
|---|---|
| private static final char[] GT | |
| lineIndenter | back to summary |
|---|---|
| private final char[] lineIndenter | |
| LT | back to summary |
|---|---|
| private static final char[] LT | |
| mode | back to summary |
|---|---|
| private final int mode | |
| newLine | back to summary |
|---|---|
| private String newLine | |
| NULL | back to summary |
|---|---|
| private static final char[] NULL | |
| QUOT | back to summary |
|---|---|
| private static final char[] QUOT | |
| readyForNewLine | back to summary |
|---|---|
| private boolean readyForNewLine | |
| tagInProgress | back to summary |
|---|---|
| private boolean tagInProgress | |
| tagIsEmpty | back to summary |
|---|---|
| private boolean tagIsEmpty | |
| writer | back to summary |
|---|---|
| private final QuickWriter writer | |
| XML_1_0 | back to summary |
|---|---|
| public static int XML_1_0 | |
| XML_1_1 | back to summary |
|---|---|
| public static int XML_1_1 | |
| XML_QUIRKS | back to summary |
|---|---|
| public static int XML_QUIRKS | |
| PrettyPrintWriter | back to summary |
|---|---|
| private PrettyPrintWriter(Writer writer, int mode, char[] lineIndenter, NameCoder nameCoder, String newLine) | |
| PrettyPrintWriter | back to summary |
|---|---|
| public PrettyPrintWriter(Writer writer, char[] lineIndenter, String newLine, XmlFriendlyReplacer replacer)
Deprecated As of 1.3
| |
| PrettyPrintWriter | back to summary |
|---|---|
public PrettyPrintWriter(Writer writer, int mode, char[] lineIndenter, NameCoder nameCoder)
| |
| PrettyPrintWriter | back to summary |
|---|---|
| public PrettyPrintWriter(Writer writer, int mode, char[] lineIndenter, XmlFriendlyReplacer replacer)
Deprecated As of 1.4 use
| |
| PrettyPrintWriter | back to summary |
|---|---|
| public PrettyPrintWriter(Writer writer, char[] lineIndenter, String newLine)
Deprecated As of 1.3 | |
| PrettyPrintWriter | back to summary |
|---|---|
public PrettyPrintWriter(Writer writer, int mode, char[] lineIndenter)
| |
| PrettyPrintWriter | back to summary |
|---|---|
| public PrettyPrintWriter(Writer writer, char[] lineIndenter) | |
| PrettyPrintWriter | back to summary |
|---|---|
| public PrettyPrintWriter(Writer writer, String lineIndenter, String newLine)
Deprecated As of 1.3 | |
| PrettyPrintWriter | back to summary |
|---|---|
public PrettyPrintWriter(Writer writer, int mode, String lineIndenter)
| |
| PrettyPrintWriter | back to summary |
|---|---|
| public PrettyPrintWriter(Writer writer, String lineIndenter) | |
| PrettyPrintWriter | back to summary |
|---|---|
public PrettyPrintWriter(Writer writer, int mode, NameCoder nameCoder)
| |
| PrettyPrintWriter | back to summary |
|---|---|
| public PrettyPrintWriter(Writer writer, int mode, XmlFriendlyReplacer replacer)
Deprecated As of 1.4 use
| |
| PrettyPrintWriter | back to summary |
|---|---|
public PrettyPrintWriter(Writer writer, NameCoder nameCoder)
| |
| PrettyPrintWriter | back to summary |
|---|---|
| public PrettyPrintWriter(Writer writer, XmlFriendlyReplacer replacer)
Deprecated As of 1.4 use | |
| PrettyPrintWriter | back to summary |
|---|---|
public PrettyPrintWriter(Writer writer, int mode)
| |
| PrettyPrintWriter | back to summary |
|---|---|
| public PrettyPrintWriter(Writer writer) | |
| addAttribute | back to summary |
|---|---|
| public void addAttribute(String key, String value) Implements com. | |
| close | back to summary |
|---|---|
| public void close() Implements com. Doc from com. Close the writer, if necessary. | |
| endNode | back to summary |
|---|---|
| public void endNode() Implements com. | |
| endOfLine | back to summary |
|---|---|
| protected void endOfLine() | |
| finishTag | back to summary |
|---|---|
| private void finishTag() | |
| flush | back to summary |
|---|---|
| public void flush() Implements com. Doc from com. Flush the writer, if necessary. | |
| getNewLine | back to summary |
|---|---|
| protected String getNewLine() Retrieve the line terminator. This method returns always a line feed, since according the XML specification any parser must ignore a carriage return. Overload this method, if you need different behavior.
| |
| setValue | back to summary |
|---|---|
| public void setValue(String text) Implements com. Doc from com. Write the value (text content) of the current node. | |
| startNode | back to summary |
|---|---|
| public void startNode(String name) Implements com. | |
| startNode | back to summary |
|---|---|
| public void startNode(String name, Class<T> clazz) Overrides com. Implements com. | |
| writeAttributeValue | back to summary |
|---|---|
| protected void writeAttributeValue(QuickWriter writer, String text) | |
| writeText | back to summary |
|---|---|
| protected void writeText(QuickWriter writer, String text) | |
| writeText | back to summary |
|---|---|
| private void writeText(String text, boolean isAttribute) | |