public class XMLBuilder
extends java.lang.Object
| Constructor and Description |
|---|
XMLBuilder(boolean wantHeader)
Create an instance of XMLBuilder
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAttribute(java.lang.String name,
java.lang.String value)
Adds an attribute to an open element.
|
void |
addClosedElement(java.lang.String elementName)
Adds a closed element.
|
void |
addContent(java.lang.String content)
Adds the content to the xml.
|
void |
addContentWithCDATA(java.lang.String content)
Adds the content to the xml surrounding it with the CDATA construct.
|
void |
addElementAndContent(java.lang.String elementName,
java.lang.String content)
Adds a new element with this content and closes the element.
|
void |
addLineFeed()
Adds a line feed to the xml
|
void |
addOpenElement(java.lang.String elementName)
Adds a new element leaving the end open so you can add attributes.
|
void |
append(char c)
Appends a char to the xml.
|
void |
append(java.lang.String s)
Appends a String to the xml.
|
void |
append(java.lang.StringBuffer sb)
Appends a StringBuffer to the xml.
|
XMLBuilder |
buildCPUTime(java.lang.String identifier,
long startTime,
long endTime)
Adds the cpu time to the xml
|
void |
closeElement()
Closes and element by appending '/>'
|
void |
closeElement(java.lang.String elementName)
Closes and element by appending '</elementName>'
|
void |
closeOpenElement()
Closes an open element by appending '>'
|
void |
endElement()
Closes and element by appending '/>'
|
byte[] |
getBytes()
Returns the xml as a byte array
|
void |
indent(int spaces)
Adds a number of spaces to the xml
|
java.lang.String |
toString()
Returns the xml as a string
|
public XMLBuilder(boolean wantHeader)
wantHeader - if set true includes <?xml version="1.0"?>public void addOpenElement(java.lang.String elementName)
elementName - is the name of the element.public void addClosedElement(java.lang.String elementName)
elementName - is the name of the element.public void addElementAndContent(java.lang.String elementName,
java.lang.String content)
elementName - is the element namecontent - is the element content.public void addAttribute(java.lang.String name,
java.lang.String value)
name - is the attribute namevalue - is the value for the attribute.public void endElement()
public void closeOpenElement()
public void closeElement()
public void closeElement(java.lang.String elementName)
elementName - is the close element name.public void append(char c)
c - is the char to append.public void append(java.lang.String s)
s - is the String to append.public void append(java.lang.StringBuffer sb)
sb - is the StringBuffer to append.public void addContent(java.lang.String content)
content - is the content to append.public void addContentWithCDATA(java.lang.String content)
content - is the content to append.public byte[] getBytes()
public java.lang.String toString()
toString in class java.lang.Objectpublic void addLineFeed()
public void indent(int spaces)
spaces - is the number of spaces to add.public XMLBuilder buildCPUTime(java.lang.String identifier, long startTime, long endTime)
identifier - is an attribute 'identifier' to addstartTime - is the StartTime in milliseconds attributeendTime - is the endTime in milliseconds attribute value
Looks like '<CPUTime identifier="identifier"
format="milliseconds"
startTime="startTime"
endTime="endTime"
totalTime="hh:mm:ss:ii"/>