public class XMLStringBuffer
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
DEFAULT_INDENT_INCREMENT
Tab space indent for XML document
|
private java.lang.String |
defaultComment |
static java.lang.String |
EOL
End of line, value of 'line.separator' system property or '\n'
|
private static java.util.regex.Pattern |
INVALID_XML_CHARS |
private IBuffer |
m_buffer
The buffer to hold the xml document
|
private java.lang.String |
m_currentIndent
A string of space character representing the current indentation.
|
private java.util.Stack<Tag> |
m_tagStack
The stack of tags to make sure XML document is well formed.
|
Constructor and Description |
---|
XMLStringBuffer() |
XMLStringBuffer(IBuffer buffer,
java.lang.String start) |
XMLStringBuffer(java.lang.String start) |
Modifier and Type | Method and Description |
---|---|
void |
addCDATA(java.lang.String content)
Add a CDATA tag.
|
void |
addComment(java.lang.String comment) |
void |
addEmptyElement(java.lang.String tagName)
Add an empty element tag (e.g.
|
void |
addEmptyElement(java.lang.String tagName,
java.util.Properties attributes)
Add an empty element tag (e.g.
|
void |
addEmptyElement(java.lang.String tagName,
java.lang.String... attributes) |
void |
addOptional(java.lang.String tagName,
java.lang.Boolean value)
Add an optional Boolean element to the current tag.
|
void |
addOptional(java.lang.String tagName,
java.lang.Boolean value,
java.util.Properties attributes)
Add an optional Boolean element to the current tag.
|
void |
addOptional(java.lang.String tagName,
java.lang.String value)
Add an optional String element to the current tag.
|
void |
addOptional(java.lang.String tagName,
java.lang.String value,
java.util.Properties attributes)
Add an optional String element to the current tag.
|
void |
addOptional(java.lang.String tagName,
java.lang.String value,
java.lang.String... attributes) |
void |
addRequired(java.lang.String tagName,
java.lang.String value)
Add a required element to the current tag.
|
void |
addRequired(java.lang.String tagName,
java.lang.String value,
java.util.Properties attributes)
Add a required element to the current tag.
|
void |
addRequired(java.lang.String tagName,
java.lang.String value,
java.lang.String... attributes) |
void |
addString(java.lang.String s) |
private java.util.Properties |
createProperties(java.lang.String[] attributes) |
java.lang.String |
getCurrentIndent() |
IBuffer |
getStringBuffer() |
private void |
init(IBuffer buffer,
java.lang.String start) |
private void |
init(IBuffer buffer,
java.lang.String start,
java.lang.String version,
java.lang.String encoding) |
void |
pop()
Pop the last pushed element without verifying it if matches the previously
pushed tag.
|
void |
pop(java.lang.String tagName)
Pop the last pushed element and throws an AssertionError if it doesn't
match the corresponding tag that was pushed earlier.
|
void |
push(java.lang.String tagName)
Push a new tag.
|
void |
push(java.lang.String tagName,
java.util.Properties attributes)
Push a new tag.
|
void |
push(java.lang.String tagName,
java.lang.String... attributes) |
void |
push(java.lang.String tagName,
java.lang.String schema)
Push a new tag.
|
void |
push(java.lang.String tagName,
java.lang.String schema,
java.util.Properties attributes)
Push a new tag.
|
void |
setDefaultComment(java.lang.String defaultComment) |
void |
setDocType(java.lang.String docType)
Set the doctype for this document.
|
void |
setXmlDetails(java.lang.String v,
java.lang.String enc)
Set the xml version and encoding for this document.
|
void |
toWriter(java.io.Writer fw) |
java.lang.String |
toXML() |
public static final java.lang.String EOL
private static final java.lang.String DEFAULT_INDENT_INCREMENT
private IBuffer m_buffer
private final java.util.Stack<Tag> m_tagStack
private java.lang.String m_currentIndent
private java.lang.String defaultComment
private static final java.util.regex.Pattern INVALID_XML_CHARS
public XMLStringBuffer()
public XMLStringBuffer(java.lang.String start)
start
- A string of spaces indicating the indentation at which
to start the generation. This constructor will not insert an
public XMLStringBuffer(IBuffer buffer, java.lang.String start)
buffer
- The StringBuffer to use internally to represent the
document.start
- A string of spaces indicating the indentation at which
to start the generation.private void init(IBuffer buffer, java.lang.String start)
private void init(IBuffer buffer, java.lang.String start, @Nullable java.lang.String version, @Nullable java.lang.String encoding)
start
- A string of spaces indicating the indentation at which
to start the generation.public void setXmlDetails(java.lang.String v, java.lang.String enc)
v
- the XML versionenc
- the XML encodingpublic void setDocType(java.lang.String docType)
docType
- The DOCTYPE string, without the "<!DOCTYPE " ">"public void push(java.lang.String tagName, @Nullable java.lang.String schema, @Nullable java.util.Properties attributes)
tagName
- The name of the tag.schema
- The schema to use (can be null or an empty string).attributes
- A Properties file representing the attributes (or null)public void push(java.lang.String tagName, @Nullable java.lang.String schema)
tagName
- The name of the tag.schema
- The schema to use (can be null or an empty string).public void push(java.lang.String tagName, @Nullable java.util.Properties attributes)
tagName
- The name of the tag.attributes
- A Properties file representing the attributes (or null)public void push(java.lang.String tagName, java.lang.String... attributes)
private java.util.Properties createProperties(java.lang.String[] attributes)
public void push(java.lang.String tagName)
tagName
- The name of the tag.public void pop()
public void pop(java.lang.String tagName)
tagName
- The name of the tag this pop() is supposed to match.public void addRequired(java.lang.String tagName, @Nullable java.lang.String value)
tagName
- The name of the tagvalue
- The value for this tagpublic void addRequired(java.lang.String tagName, @Nullable java.lang.String value, @Nullable java.util.Properties attributes)
tagName
- The name of the tagvalue
- The value for this tagattributes
- A Properties file containing the attributes (or null)public void addRequired(java.lang.String tagName, @Nullable java.lang.String value, java.lang.String... attributes)
public void addOptional(java.lang.String tagName, @Nullable java.lang.String value, @Nullable java.util.Properties attributes)
tagName
- The name of the tagvalue
- The value for this tagattributes
- A Properties file containing the attributes (or null)public void addOptional(java.lang.String tagName, @Nullable java.lang.String value, java.lang.String... attributes)
public void addOptional(java.lang.String tagName, @Nullable java.lang.String value)
tagName
- The name of the tagvalue
- The value for this tagpublic void addOptional(java.lang.String tagName, @Nullable java.lang.Boolean value, @Nullable java.util.Properties attributes)
tagName
- The name of the tagvalue
- The value for this tagattributes
- A Properties file containing the attributes (or null)public void addOptional(java.lang.String tagName, @Nullable java.lang.Boolean value)
tagName
- The name of the tagvalue
- The value for this tagpublic void addEmptyElement(java.lang.String tagName)
tagName
- The name of the tagpublic void addEmptyElement(java.lang.String tagName, @Nullable java.util.Properties attributes)
tagName
- The name of the tagattributes
- A Properties file containing the attributes (or null)public void addEmptyElement(java.lang.String tagName, java.lang.String... attributes)
public void addComment(java.lang.String comment)
public void addString(java.lang.String s)
public void setDefaultComment(java.lang.String defaultComment)
public void addCDATA(java.lang.String content)
public IBuffer getStringBuffer()
public java.lang.String toXML()
public java.lang.String getCurrentIndent()
public void toWriter(java.io.Writer fw)