Package org.apache.juneau.xml
Class XmlWriter
java.lang.Object
java.io.Writer
org.apache.juneau.serializer.SerializerWriter
org.apache.juneau.xml.XmlWriter
- All Implemented Interfaces:
- Closeable,- Flushable,- Appendable,- AutoCloseable
- Direct Known Subclasses:
- HtmlWriter
Specialized writer for serializing XML.
 
Notes:
- This class is not intended for external use.
See Also:
- 
Field SummaryFields inherited from class org.apache.juneau.serializer.SerializerWritermaxIndent, out, quoteChar, trimStrings, uriResolver, useWhitespace
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionappend(char c) append(int indent, char c) Writes an indent (if theuseWhitespacesetting is enabled), followed by text.Writes an indent (if theuseWhitespacesetting is enabled), followed by text.Writes the specified text to the writer if it isn'tnull .Writes the specified text to the writer if it isn'tnull .Writes an indent (if theuseWhitespacesetting is enabled), followed by text, followed by a newline (if theuseWhitespacesetting is enabled).Writes the specified text followed by a newline (if theuseWhitespacesetting is enabled).Shortcut forattr(null , name, value,false );Shortcut forattr(null , name, value,false );Shortcut forattr(ns, name, value,false );Writes an attribute to the output:ns:name ='value' Same asattr(String, String, Object), except pass in aNamespaceobject for the namespace.Append an attribute with a URI value.Writes an attribute with a URI value to the output:ns:name ='uri-value' Writes an attribute with a URI value to the output:ns:name ='uri-value' ceTag()Closes an empty tag.cr(int depth) Performs a carriage return.cre(int depth) Performs a carriage return at the end of a line.cTag()Closes a tag.Shortcut fori(indent).eTag(null , name,false );Shortcut fori(indent).eTag(ns, name,false );Shortcut fori(indent).eTag(ns, name, needsEncoding); Shortcut foreTag(null , name,false );Shortcut foreTag(ns, name,false );Writes an end tag to the output:</ns:name> i(int indent) Writes an indent to the writer if theuseWhitespacesetting is enabled.ie(int indent) Writes an end-of-line indent to the writer if theuseWhitespacesetting is enabled.nl(int indent) Writes a newline to the writer if theuseWhitespacesetting is enabled.Writes an open-ended attribute to the output:ns:name =Writes an open-ended attribute to the output:ns:name =Shortcut fori(indent).oTag(null , name,false );Shortcut fori(indent).oTag(ns, name,false );Shortcut fori(indent).oTag(ns, name, needsEncoding); Shortcut foroTag(null , name,false );Shortcut foroTag(ns, name,false );Writes an opening tag to the output:<ns:name q()Adds the quote character specified by thequoteCharsetting to the output.s()Adds a whitespace character to the output if theuseWhitespacesetting is enabled.Shortcut fori(indent).sTag(null , name,false );Shortcut fori(indent).sTag(ns, name,false );Shortcut fori(indent).sTag(ns, name, needsEncoding); Shortcut forsTag(null , name,false );Shortcut forsTag(ns, name,false );Writes a start tag to the output:<ns:name> Shortcut fori(indent).tag(null , name,false );Shortcut fori(indent).tag(ns, name,false );Shortcut fori(indent).tag(ns, name, needsEncoding); Shortcut fortag(null , name,false );Shortcut fortag(ns, name,false );Writes a closed tag to the output:<ns:name/> Shortcut for callingtext(o,false );Serializes and encodes the specified object as valid XML text.Same astext(Object)but treats the value as a URL to resolved then serialized.toString()w(char c) Writes the specified character to the writer.Writes the specified string to the writer.
- 
Constructor Details- 
XmlWriterpublic XmlWriter(Writer out, boolean useWhitespace, int maxIndent, boolean trimStrings, char quoteChar, UriResolver uriResolver, boolean enableNs, Namespace defaultNamespace) Constructor.- Parameters:
- out- The wrapped writer.
- useWhitespace- If- true XML elements will be indented.
- maxIndent- The maximum indentation level.
- trimStrings- If- true , strings should be trimmed before they're serialized.
- quoteChar- The quote character to use for attributes. Should be- '\'' or- '"' .
- 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.
 
- 
XmlWriterCopy constructor.- Parameters:
- w- Writer being copied.
 
 
- 
- 
Method Details- 
oTagWrites an opening tag to the output:<ns:name - Parameters:
- ns- The namespace. Can be- null .
- name- The element name.
- needsEncoding- If- true , element name will be encoded.
- Returns:
- This object.
 
- 
oTagShortcut foroTag(ns, name,false );- Parameters:
- ns- The namespace. Can be- null .
- name- The element name.
- Returns:
- This object.
 
- 
oTagShortcut foroTag(null , name,false );- Parameters:
- name- The element name.
- Returns:
- This object.
 
- 
oTagShortcut fori(indent).oTag(ns, name, needsEncoding); - Parameters:
- indent- The number of prefix tabs to add.
- ns- The namespace. Can be- null .
- name- The element name.
- needsEncoding- If- true , element name will be encoded.
- Returns:
- This object.
 
- 
oTagShortcut fori(indent).oTag(ns, name,false );- Parameters:
- indent- The number of prefix tabs to add.
- ns- The namespace. Can be- null .
- name- The element name.
- Returns:
- This object.
 
- 
oTagShortcut fori(indent).oTag(null , name,false );- Parameters:
- indent- The number of prefix tabs to add.
- name- The element name.
- Returns:
- This object.
 
- 
cTagCloses a tag.Shortcut for append('->' );- Returns:
- This object.
 
- 
ceTagCloses an empty tag.Shortcut for append('/' ).append('->' );- Returns:
- This object.
 
- 
tagWrites a closed tag to the output:<ns:name/> - Parameters:
- ns- The namespace. Can be- null .
- name- The element name.
- needsEncoding- If- true , element name will be encoded.
- Returns:
- This object.
 
- 
tagShortcut fortag(ns, name,false );- Parameters:
- ns- The namespace. Can be- null .
- name- The element name.
- Returns:
- This object.
 
- 
tagShortcut fortag(null , name,false );- Parameters:
- name- The element name.
- Returns:
- This object.
 
- 
tagShortcut fori(indent).tag(null , name,false );- Parameters:
- indent- The number of prefix tabs to add.
- name- The element name.
- Returns:
- This object.
 
- 
tagShortcut fori(indent).tag(ns, name, needsEncoding); - Parameters:
- indent- The number of prefix tabs to add.
- ns- The namespace. Can be- null .
- name- The element name.
- needsEncoding- If- true , element name will be encoded.
- Returns:
- This object.
 
- 
tagShortcut fori(indent).tag(ns, name,false );- Parameters:
- indent- The number of prefix tabs to add.
- ns- The namespace. Can be- null .
- name- The element name.
- Returns:
- This object.
 
- 
sTagWrites a start tag to the output:<ns:name> - Parameters:
- ns- The namespace. Can be- null .
- name- The element name.
- needsEncoding- If- true , element name will be encoded.
- Returns:
- This object.
 
- 
sTagShortcut forsTag(ns, name,false );- Parameters:
- ns- The namespace. Can be- null .
- name- The element name.
- Returns:
- This object.
 
- 
sTagShortcut forsTag(null , name,false );- Parameters:
- name- The element name.
- Returns:
- This object.
 
- 
sTagShortcut fori(indent).sTag(ns, name, needsEncoding); - Parameters:
- indent- The number of prefix tabs to add.
- ns- The namespace. Can be- null .
- name- The element name.
- needsEncoding- If- true , element name will be encoded.
- Returns:
- This object.
 
- 
sTagShortcut fori(indent).sTag(ns, name,false );- Parameters:
- indent- The number of prefix tabs to add.
- ns- The namespace. Can be- null .
- name- The element name.
- Returns:
- This object.
 
- 
sTagShortcut fori(indent).sTag(null , name,false );- Parameters:
- indent- The number of prefix tabs to add.
- name- The element name.
- Returns:
- This object.
 
- 
eTagWrites an end tag to the output:</ns:name> - Parameters:
- ns- The namespace. Can be- null .
- name- The element name.
- needsEncoding- If- true , element name will be encoded.
- Returns:
- This object.
 
- 
eTagShortcut foreTag(ns, name,false );- Parameters:
- ns- The namespace. Can be- null .
- name- The element name.
- Returns:
- This object.
 
- 
eTagShortcut foreTag(null , name,false );- Parameters:
- name- The element name.
- Returns:
- This object.
 
- 
eTagShortcut fori(indent).eTag(ns, name, needsEncoding); - Parameters:
- indent- The number of prefix tabs to add.
- ns- The namespace. Can be- null .
- name- The element name.
- needsEncoding- If- true , element name will be encoded.
- Returns:
- This object.
 
- 
eTagShortcut fori(indent).eTag(ns, name,false );- Parameters:
- indent- The number of prefix tabs to add.
- ns- The namespace. Can be- null .
- name- The element name.
- Returns:
- This object.
 
- 
eTagShortcut fori(indent).eTag(null , name,false );- Parameters:
- indent- The number of prefix tabs to add.
- name- The element name.
- Returns:
- This object.
 
- 
attrWrites an attribute to the output:ns:name ='value' - Parameters:
- ns- The namespace. Can be- null .
- name- The attribute name.
- value- The attribute value.
- valNeedsEncoding- If- true , attribute name will be encoded.
- Returns:
- This object.
 
- 
attrShortcut forattr(null , name, value,false );- Parameters:
- name- The attribute name.
- value- The attribute value.
- valNeedsEncoding- If- true , attribute name will be encoded.
- Returns:
- This object.
 
- 
attrShortcut forattr(ns, name, value,false );- Parameters:
- ns- The namespace. Can be- null .
- name- The attribute name.
- value- The attribute value.
- Returns:
- This object.
 
- 
attrSame asattr(String, String, Object), except pass in aNamespaceobject for the namespace.- Parameters:
- ns- The namespace. Can be- null .
- name- The attribute name.
- value- The attribute value.
- Returns:
- This object.
 
- 
attrShortcut forattr(null , name, value,false );- Parameters:
- name- The attribute name.
- value- The attribute value.
- Returns:
- This object.
 
- 
oAttrWrites an open-ended attribute to the output:ns:name =- Parameters:
- ns- The namespace. Can be- null .
- name- The attribute name.
- Returns:
- This object.
 
- 
oAttrWrites an open-ended attribute to the output:ns:name =- Parameters:
- ns- The namespace. Can be- null .
- name- The attribute name.
- Returns:
- This object.
 
- 
attrUriWrites an attribute with a URI value to the output:ns:name ='uri-value' - Parameters:
- ns- The namespace. Can be- null .
- name- The attribute name.
- value- The attribute value, convertible to a URI via- toString() 
- Returns:
- This object.
 
- 
attrUriWrites an attribute with a URI value to the output:ns:name ='uri-value' - Parameters:
- ns- The namespace. Can be- null .
- name- The attribute name.
- value- The attribute value, convertible to a URI via- toString() 
- Returns:
- This object.
 
- 
attrUriAppend an attribute with a URI value.- Parameters:
- name- The attribute name.
- value- The attribute value. Can be any object whose- toString() method returns a URI.
- Returns:
- This object.
 
- 
textShortcut for callingtext(o,false );- Parameters:
- value- The object being serialized.
- Returns:
- This object.
 
- 
textSerializes and encodes the specified object as valid XML text.- Parameters:
- value- The object being serialized.
- preserveWhitespace- If- true , then we're serializing- XmlFormat.MIXED_PWSor- XmlFormat.TEXT_PWScontent.
- Returns:
- This object.
 
- 
textUriSame astext(Object)but treats the value as a URL to resolved then serialized.- Parameters:
- value- The object being serialized.
- Returns:
- This object.
 
- 
crDescription copied from class:SerializerWriterPerforms a carriage return.Adds a newline and the specified number of tabs (if the useWhitespacesetting is enabled) to the output.- Overrides:
- crin class- SerializerWriter
- Parameters:
- depth- The indentation.
- Returns:
- This object.
 
- 
creDescription copied from class:SerializerWriterPerforms a carriage return at the end of a line.Adds a newline and the specified number of tabs (if the useWhitespacesetting is enabled) to the output.- Overrides:
- crein class- SerializerWriter
- Parameters:
- depth- The indentation.
- Returns:
- This object.
 
- 
appendlnDescription copied from class:SerializerWriterWrites an indent (if theuseWhitespacesetting is enabled), followed by text, followed by a newline (if theuseWhitespacesetting is enabled).- Overrides:
- appendlnin class- SerializerWriter
- Parameters:
- indent- The number of tabs to indent.
- text- The text to write.
- Returns:
- This object.
 
- 
appendlnDescription copied from class:SerializerWriterWrites the specified text followed by a newline (if theuseWhitespacesetting is enabled).- Overrides:
- appendlnin class- SerializerWriter
- Parameters:
- text- The text to write.
- Returns:
- This object.
 
- 
appendDescription copied from class:SerializerWriterWrites an indent (if theuseWhitespacesetting is enabled), followed by text.- Overrides:
- appendin class- SerializerWriter
- Parameters:
- indent- The number of tabs to indent.
- text- The text to write.
- Returns:
- This object.
 
- 
appendDescription copied from class:SerializerWriterWrites an indent (if theuseWhitespacesetting is enabled), followed by text.- Overrides:
- appendin class- SerializerWriter
- Parameters:
- indent- The number of tabs to indent.
- c- The character to write.
- Returns:
- This object.
 
- 
sDescription copied from class:SerializerWriterAdds a whitespace character to the output if theuseWhitespacesetting is enabled.- Overrides:
- sin class- SerializerWriter
- Returns:
- This object.
 
- 
qDescription copied from class:SerializerWriterAdds the quote character specified by thequoteCharsetting to the output.- Overrides:
- qin class- SerializerWriter
- Returns:
- This object.
 
- 
iDescription copied from class:SerializerWriterWrites an indent to the writer if theuseWhitespacesetting is enabled.- Overrides:
- iin class- SerializerWriter
- Parameters:
- indent- The number of tabs to indent.
- Returns:
- This object.
 
- 
ieDescription copied from class:SerializerWriterWrites an end-of-line indent to the writer if theuseWhitespacesetting is enabled.- Overrides:
- iein class- SerializerWriter
- Parameters:
- indent- The number of tabs to indent.
- Returns:
- This object.
 
- 
nlDescription copied from class:SerializerWriterWrites a newline to the writer if theuseWhitespacesetting is enabled.- Overrides:
- nlin class- SerializerWriter
- Parameters:
- indent- The current indentation level.
- Returns:
- This object.
 
- 
appendDescription copied from class:SerializerWriterWrites the specified text to the writer if it isn'tnull .- Overrides:
- appendin class- SerializerWriter
- Parameters:
- text- The text to write.
- Returns:
- This object.
 
- 
appendDescription copied from class:SerializerWriterWrites the specified text to the writer if it isn'tnull .- Overrides:
- appendin class- SerializerWriter
- Parameters:
- text- The text to write.
- Returns:
- This object.
 
- 
append- Specified by:
- appendin interface- Appendable
- Overrides:
- appendin class- SerializerWriter
 
- 
wDescription copied from class:SerializerWriterWrites the specified character to the writer.- Overrides:
- win class- SerializerWriter
- Parameters:
- c- The character to write.
- Returns:
- This object.
 
- 
wDescription copied from class:SerializerWriterWrites the specified string to the writer.- Overrides:
- win class- SerializerWriter
- Parameters:
- s- The string to write.
- Returns:
- This object.
 
- 
toString
 
-