public class

XmlBuilder

extends TextBuilder
java.lang.Object
   ↳ com.pnfsoftware.jeb.util.format.TextBuilder
     ↳ com.pnfsoftware.jeb.util.format.XmlBuilder

Class Overview

A specialized text builder used to craft XML documents sequentially.

Summary

Public Constructors
XmlBuilder()
XmlBuilder(int indentationSize)
XmlBuilder(int indentationSize, int initialCapacity)
Public Methods
void appendHeader(int versionMajor, int versionMinor, String encoding, boolean standalone)
Append an XML header.
void appendStandardHeader()
Append a standard 1.0 header specifying a UTF-8 encoding and standalone=no.
void closeElement()
Close the last opened element.
void closeElement(boolean appendLine)
Close the last opened element.
static CharSequence escapeAll(CharSequence s)
static CharSequence escapeAttributeData(CharSequence s)
Escape an XML attribute data string.
static CharSequence escapeTextData(CharSequence s)
Escape an XML text data string.
void openElement(String name)
Output an XML element with attributes.
void openElement(String name, Map<String, String> attributes)
Output an XML element with attributes.
void openElement(String name, Map<String, String> attributes, boolean close)
Output an XML element with attributes.
[Expand]
Inherited Methods
From class com.pnfsoftware.jeb.util.format.TextBuilder
From class java.lang.Object
From interface java.lang.Appendable

Public Constructors

public XmlBuilder ()

public XmlBuilder (int indentationSize)

public XmlBuilder (int indentationSize, int initialCapacity)

Public Methods

public void appendHeader (int versionMajor, int versionMinor, String encoding, boolean standalone)

Append an XML header.

public void appendStandardHeader ()

Append a standard 1.0 header specifying a UTF-8 encoding and standalone=no.

public void closeElement ()

Close the last opened element.

public void closeElement (boolean appendLine)

Close the last opened element.

Parameters
appendLine if true, a new line is appended after the closing tag

public static CharSequence escapeAll (CharSequence s)

public static CharSequence escapeAttributeData (CharSequence s)

Escape an XML attribute data string.

public static CharSequence escapeTextData (CharSequence s)

Escape an XML text data string.

public void openElement (String name)

Output an XML element with attributes. The element is not not output

public void openElement (String name, Map<String, String> attributes)

Output an XML element with attributes. The closing tag is not output.

Parameters
attributes optional attributes

public void openElement (String name, Map<String, String> attributes, boolean close)

Output an XML element with attributes.

Parameters
name the element name
attributes optional map of attributes name->value, which must be escaped (this method will append the attributes' names and values as-is)
close if true, the tag is immediately closed using "/>"