public class XmlWriter extends SerializerWriter
maxIndent, out, quoteChar, trimStrings, uriResolver, useWhitespace
Constructor and Description |
---|
XmlWriter(Writer out,
boolean useWhitespace,
int maxIndent,
boolean trimStrings,
char quoteChar,
UriResolver uriResolver,
boolean enableNs,
Namespace defaultNamespace)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
XmlWriter |
append(char c) |
XmlWriter |
append(int indent,
char c)
Writes an indent (if the
useWhitespace setting is enabled), followed by text. |
XmlWriter |
append(int indent,
String text)
Writes an indent (if the
useWhitespace setting is enabled), followed by text. |
XmlWriter |
append(Object text)
Writes the specified text to the writer.
|
XmlWriter |
append(String text)
Writes the specified text to the writer.
|
XmlWriter |
appendln(int indent,
String text)
Writes an indent (if the
useWhitespace setting is enabled), followed by text, followed by a newline
(if the useWhitespace setting is enabled). |
XmlWriter |
appendln(String text)
Writes the specified text followed by a newline (if the
useWhitespace setting is enabled). |
XmlWriter |
attr(Namespace ns,
String name,
Object value)
Same as
attr(String, String, Object) , except pass in a Namespace object for the namespace. |
XmlWriter |
attr(String name,
Object value)
Shortcut for
attr( |
XmlWriter |
attr(String name,
Object value,
boolean valNeedsEncoding)
Shortcut for
attr( |
XmlWriter |
attr(String ns,
String name,
Object value)
Shortcut for
attr(ns, name, value, |
XmlWriter |
attr(String ns,
String name,
Object value,
boolean valNeedsEncoding)
Writes an attribute to the output:
|
XmlWriter |
attrUri(Namespace ns,
String name,
Object value)
Writes an attribute with a URI value to the output:
|
XmlWriter |
attrUri(String ns,
String name,
Object value)
Writes an attribute with a URI value to the output:
|
XmlWriter |
ceTag()
Closes an empty tag.
|
XmlWriter |
cr(int depth)
Performs a carriage return.
|
XmlWriter |
cre(int depth)
Performs a carriage return at the end of a line.
|
XmlWriter |
cTag()
Closes a tag.
|
XmlWriter |
eTag(int indent,
String name)
Shortcut for
i(indent).eTag( |
XmlWriter |
eTag(int indent,
String ns,
String name)
Shortcut for
i(indent).eTag(ns, name, |
XmlWriter |
eTag(int indent,
String ns,
String name,
boolean needsEncoding)
Shortcut for
i(indent).eTag(ns, name, needsEncoding); |
XmlWriter |
eTag(String name)
Shortcut for
eTag( |
XmlWriter |
eTag(String ns,
String name)
Shortcut for
eTag(ns, name, |
XmlWriter |
eTag(String ns,
String name,
boolean needsEncoding)
Writes an end tag to the output:
|
XmlWriter |
i(int indent)
Writes an indent to the writer if the
useWhitespace setting is enabled. |
XmlWriter |
ie(int indent)
Writes an end-of-line indent to the writer if the
useWhitespace setting is enabled. |
XmlWriter |
nl(int indent)
Writes a newline to the writer if the
useWhitespace setting is enabled. |
XmlWriter |
oAttr(Namespace ns,
String name)
Writes an open-ended attribute to the output:
|
XmlWriter |
oAttr(String ns,
String name)
Writes an open-ended attribute to the output:
|
XmlWriter |
oTag(int indent,
String name)
Shortcut for
i(indent).oTag( |
XmlWriter |
oTag(int indent,
String ns,
String name)
Shortcut for
i(indent).oTag(ns, name, |
XmlWriter |
oTag(int indent,
String ns,
String name,
boolean needsEncoding)
Shortcut for
i(indent).oTag(ns, name, needsEncoding); |
XmlWriter |
oTag(String name)
Shortcut for
oTag( |
XmlWriter |
oTag(String ns,
String name)
Shortcut for
oTag(ns, name, |
XmlWriter |
oTag(String ns,
String name,
boolean needsEncoding)
Writes an opening tag to the output:
|
XmlWriter |
q()
Adds the quote character specified by the
quoteChar setting to the output. |
XmlWriter |
s()
Adds a whitespace character to the output if the
useWhitespace setting is enabled. |
XmlWriter |
sTag(int indent,
String name)
Shortcut for
i(indent).sTag( |
XmlWriter |
sTag(int indent,
String ns,
String name)
Shortcut for
i(indent).sTag(ns, name, |
XmlWriter |
sTag(int indent,
String ns,
String name,
boolean needsEncoding)
Shortcut for
i(indent).sTag(ns, name, needsEncoding); |
XmlWriter |
sTag(String name)
Shortcut for
sTag( |
XmlWriter |
sTag(String ns,
String name)
Shortcut for
sTag(ns, name, |
XmlWriter |
sTag(String ns,
String name,
boolean needsEncoding)
Writes a start tag to the output:
|
XmlWriter |
tag(int indent,
String name)
Shortcut for
i(indent).tag( |
XmlWriter |
tag(int indent,
String ns,
String name)
Shortcut for
i(indent).tag(ns, name, |
XmlWriter |
tag(int indent,
String ns,
String name,
boolean needsEncoding)
Shortcut for
i(indent).tag(ns, name, needsEncoding); |
XmlWriter |
tag(String name)
Shortcut for
tag( |
XmlWriter |
tag(String ns,
String name)
Shortcut for
tag(ns, name, |
XmlWriter |
tag(String ns,
String name,
boolean needsEncoding)
Writes a closed tag to the output:
|
XmlWriter |
text(Object o)
Shortcut for calling
text(o, |
XmlWriter |
text(Object o,
boolean preserveWhitespace)
Serializes and encodes the specified object as valid XML text.
|
XmlWriter |
textUri(Object o)
Same as
text(Object) but treats the value as a URL to resolved then serialized. |
String |
toString() |
public XmlWriter(Writer out, boolean useWhitespace, int maxIndent, boolean trimStrings, char quoteChar, UriResolver uriResolver, boolean enableNs, Namespace defaultNamespace)
out
- The wrapped writer.useWhitespace
- If maxIndent
- The maximum indentation level.trimStrings
- If quoteChar
- The quote character to use for attributes. Should be uriResolver
- The URI resolver for resolving URIs to absolute or root-relative form.enableNs
- Flag to indicate if XML namespaces are enabled.defaultNamespace
- The default namespace if XML namespaces are enabled.public XmlWriter oTag(String ns, String name, boolean needsEncoding) throws IOException
<ns:name
ns
- The namespace. Can be name
- The element name.needsEncoding
- If IOException
- If a problem occurred.public XmlWriter oTag(String ns, String name) throws IOException
oTag(ns, name, false );
ns
- The namespace. Can be name
- The element name.IOException
- If a problem occurred.public XmlWriter oTag(String name) throws IOException
oTag(null , name, false );
name
- The element name.IOException
- If a problem occurred.public XmlWriter oTag(int indent, String ns, String name, boolean needsEncoding) throws IOException
i(indent).oTag(ns, name, needsEncoding);
indent
- The number of prefix tabs to add.ns
- The namespace. Can be name
- The element name.needsEncoding
- If IOException
- If a problem occurred.public XmlWriter oTag(int indent, String ns, String name) throws IOException
i(indent).oTag(ns, name, false );
indent
- The number of prefix tabs to add.ns
- The namespace. Can be name
- The element name.IOException
- If a problem occurred.public XmlWriter oTag(int indent, String name) throws IOException
i(indent).oTag(null , name, false );
indent
- The number of prefix tabs to add.name
- The element name.IOException
- If a problem occurred.public XmlWriter cTag() throws IOException
Shortcut for append(
IOException
public XmlWriter ceTag() throws IOException
Shortcut for append(
IOException
public XmlWriter tag(String ns, String name, boolean needsEncoding) throws IOException
<ns:name/>
ns
- The namespace. Can be name
- The element name.needsEncoding
- If IOException
- If a problem occurred.public XmlWriter tag(String ns, String name) throws IOException
tag(ns, name, false );
ns
- The namespace. Can be name
- The element name.IOException
- If a problem occurred.public XmlWriter tag(String name) throws IOException
tag(null , name, false );
name
- The element name.IOException
- If a problem occurred.public XmlWriter tag(int indent, String name) throws IOException
i(indent).tag(null , name, false );
indent
- The number of prefix tabs to add.name
- The element name.IOException
- If a problem occurred.public XmlWriter tag(int indent, String ns, String name, boolean needsEncoding) throws IOException
i(indent).tag(ns, name, needsEncoding);
indent
- The number of prefix tabs to add.ns
- The namespace. Can be name
- The element name.needsEncoding
- If IOException
- If a problem occurred.public XmlWriter tag(int indent, String ns, String name) throws IOException
i(indent).tag(ns, name, false );
indent
- The number of prefix tabs to add.ns
- The namespace. Can be name
- The element name.IOException
- If a problem occurred.public XmlWriter sTag(String ns, String name, boolean needsEncoding) throws IOException
<ns:name>
ns
- The namespace. Can be name
- The element name.needsEncoding
- If IOException
- If a problem occurred.public XmlWriter sTag(String ns, String name) throws IOException
sTag(ns, name, false );
ns
- The namespace. Can be name
- The element name.IOException
- If a problem occurred.public XmlWriter sTag(String name) throws IOException
sTag(null , name, false );
name
- The element name.IOException
- If a problem occurred.public XmlWriter sTag(int indent, String ns, String name, boolean needsEncoding) throws IOException
i(indent).sTag(ns, name, needsEncoding);
indent
- The number of prefix tabs to add.ns
- The namespace. Can be name
- The element name.needsEncoding
- If IOException
- If a problem occurred.public XmlWriter sTag(int indent, String ns, String name) throws IOException
i(indent).sTag(ns, name, false );
indent
- The number of prefix tabs to add.ns
- The namespace. Can be name
- The element name.IOException
- If a problem occurred.public XmlWriter sTag(int indent, String name) throws IOException
i(indent).sTag(null , name, false );
indent
- The number of prefix tabs to add.name
- The element name.IOException
- If a problem occurred.public XmlWriter eTag(String ns, String name, boolean needsEncoding) throws IOException
</ns:name>
ns
- The namespace. Can be name
- The element name.needsEncoding
- If IOException
- If a problem occurred.public XmlWriter eTag(String ns, String name) throws IOException
eTag(ns, name, false );
ns
- The namespace. Can be name
- The element name.IOException
- If a problem occurred.public XmlWriter eTag(String name) throws IOException
eTag(null , name, false );
name
- The element name.IOException
- If a problem occurred.public XmlWriter eTag(int indent, String ns, String name, boolean needsEncoding) throws IOException
i(indent).eTag(ns, name, needsEncoding);
indent
- The number of prefix tabs to add.ns
- The namespace. Can be name
- The element name.needsEncoding
- If IOException
- If a problem occurred.public XmlWriter eTag(int indent, String ns, String name) throws IOException
i(indent).eTag(ns, name, false );
indent
- The number of prefix tabs to add.ns
- The namespace. Can be name
- The element name.IOException
- If a problem occurred.public XmlWriter eTag(int indent, String name) throws IOException
i(indent).eTag(null , name, false );
indent
- The number of prefix tabs to add.name
- The element name.IOException
- If a problem occurred.public XmlWriter attr(String ns, String name, Object value, boolean valNeedsEncoding) throws IOException
ns:name ='value'
ns
- The namespace. Can be name
- The attribute name.value
- The attribute value.valNeedsEncoding
- If IOException
- If a problem occurred.public XmlWriter attr(String name, Object value, boolean valNeedsEncoding) throws IOException
attr(null , name, value, false );
name
- The attribute name.value
- The attribute value.valNeedsEncoding
- If IOException
- If a problem occurred.public XmlWriter attr(String ns, String name, Object value) throws IOException
attr(ns, name, value, false );
ns
- The namespace. Can be name
- The attribute name.value
- The attribute value.IOException
- If a problem occurred.public XmlWriter attr(Namespace ns, String name, Object value) throws IOException
attr(String, String, Object)
, except pass in a Namespace
object for the namespace.ns
- The namespace. Can be name
- The attribute name.value
- The attribute value.IOException
- If a problem occurred.public XmlWriter attr(String name, Object value) throws IOException
attr(null , name, value, false );
name
- The attribute name.value
- The attribute value.IOException
- If a problem occurred.public XmlWriter oAttr(String ns, String name) throws IOException
ns:name =
ns
- The namespace. Can be name
- The attribute name.IOException
- If a problem occurred.public XmlWriter oAttr(Namespace ns, String name) throws IOException
ns:name =
ns
- The namespace. Can be name
- The attribute name.IOException
- If a problem occurred.public XmlWriter attrUri(Namespace ns, String name, Object value) throws IOException
ns:name ='uri-value'
ns
- The namespace. Can be name
- The attribute name.value
- The attribute value, convertible to a URI via toString()
IOException
- If a problem occurred.public XmlWriter attrUri(String ns, String name, Object value) throws IOException
ns:name ='uri-value'
ns
- The namespace. Can be name
- The attribute name.value
- The attribute value, convertible to a URI via toString()
IOException
- If a problem occurred.public XmlWriter text(Object o) throws IOException
text(o, false );
o
- The object being serialized.IOException
- If a problem occurred.public XmlWriter text(Object o, boolean preserveWhitespace) throws IOException
o
- The object being serialized.preserveWhitespace
- If XmlFormat.MIXED_PWS
or XmlFormat.TEXT_PWS
content.IOException
public XmlWriter textUri(Object o) throws IOException
text(Object)
but treats the value as a URL to resolved then serialized.o
- The object being serialized.IOException
public XmlWriter cr(int depth) throws IOException
SerializerWriter
Adds a newline and the specified number of tabs (if the useWhitespace
setting is enabled) to the output.
cr
in class SerializerWriter
depth
- The indentation.IOException
- If a problem occurred trying to write to the writer.public XmlWriter cre(int depth) throws IOException
SerializerWriter
Adds a newline and the specified number of tabs (if the useWhitespace
setting is enabled) to the output.
cre
in class SerializerWriter
depth
- The indentation.IOException
- If a problem occurred trying to write to the writer.public XmlWriter appendln(int indent, String text) throws IOException
SerializerWriter
useWhitespace
setting is enabled), followed by text, followed by a newline
(if the useWhitespace
setting is enabled).appendln
in class SerializerWriter
indent
- The number of tabs to indent.text
- The text to write.IOException
- If a problem occurred trying to write to the writer.public XmlWriter appendln(String text) throws IOException
SerializerWriter
useWhitespace
setting is enabled).appendln
in class SerializerWriter
text
- The text to write.IOException
- If a problem occurred trying to write to the writer.public XmlWriter append(int indent, String text) throws IOException
SerializerWriter
useWhitespace
setting is enabled), followed by text.append
in class SerializerWriter
indent
- The number of tabs to indent.text
- The text to write.IOException
- If a problem occurred trying to write to the writer.public XmlWriter append(int indent, char c) throws IOException
SerializerWriter
useWhitespace
setting is enabled), followed by text.append
in class SerializerWriter
indent
- The number of tabs to indent.c
- The character to write.IOException
- If a problem occurred trying to write to the writer.public XmlWriter s() throws IOException
SerializerWriter
useWhitespace
setting is enabled.s
in class SerializerWriter
IOException
- If a problem occurred trying to write to the writer.public XmlWriter q() throws IOException
SerializerWriter
quoteChar
setting to the output.q
in class SerializerWriter
IOException
- If a problem occurred trying to write to the writer.public XmlWriter i(int indent) throws IOException
SerializerWriter
useWhitespace
setting is enabled.i
in class SerializerWriter
indent
- The number of tabs to indent.IOException
- If a problem occurred trying to write to the writer.public XmlWriter ie(int indent) throws IOException
SerializerWriter
useWhitespace
setting is enabled.ie
in class SerializerWriter
indent
- The number of tabs to indent.IOException
- If a problem occurred trying to write to the writer.public XmlWriter nl(int indent) throws IOException
SerializerWriter
useWhitespace
setting is enabled.nl
in class SerializerWriter
indent
- The current indentation level.IOException
- If a problem occurred trying to write to the writer.public XmlWriter append(Object text) throws IOException
SerializerWriter
append
in class SerializerWriter
text
- The text to write.IOException
- If a problem occurred trying to write to the writer.public XmlWriter append(String text) throws IOException
SerializerWriter
append
in class SerializerWriter
text
- The text to write.IOException
- If a problem occurred trying to write to the writer.public XmlWriter append(char c) throws IOException
append
in interface Appendable
append
in class SerializerWriter
IOException
Copyright © 2018 Apache. All rights reserved.