public class XmlBuilder
extends java.lang.Object
XMLBuilder also aids accuracy by correctly escaping illegal symbols in content and attribute values, and by tracking and enforcing tag nesting.
Output is attractively indented at no additional cost.
Copyright 2003-2006 Partner Software, Inc.
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
droppingElementsWithoutContent |
protected boolean |
emptyingElementsWithoutContent |
protected int |
indention |
protected DynamicCharArray |
indentSpace |
protected java.io.BufferedWriter |
outie |
protected java.util.ArrayList<java.lang.String> |
stack |
| Constructor and Description |
|---|
XmlBuilder(java.io.File outputFile) |
XmlBuilder(VfsFile outputFile) |
XmlBuilder(java.io.Writer writer) |
XmlBuilder(java.io.Writer writer,
boolean printDoctype) |
| Modifier and Type | Method and Description |
|---|---|
void |
beginStartTag(java.lang.String tagName) |
void |
close() |
void |
endElement() |
void |
endElement(boolean newLine) |
void |
endElement(java.lang.String checkTagName) |
void |
endElement(java.lang.String checkTagName,
boolean newLine) |
void |
endStartTag() |
protected void |
indent()
Increases indention level by one.
|
boolean |
isDroppingElementsWithoutContent() |
boolean |
isEmptyingElementsWithoutContent() |
protected void |
newLine()
Utility method; prints a newline and appropriate indention.
|
void |
setDroppingElementsWithoutContent(boolean droppingElementsWithoutContent)
If set to true, will not output elements specified by writeElement()
if the content is null or blank.
|
void |
setEmptyingElementsWithoutContent(boolean emptyingElementsWithoutContent)
If set to true, uses the empty element form (e.g.
|
void |
startElement(java.lang.String tagName) |
void |
startElement(java.lang.String tagName,
boolean newLine) |
void |
startElement(java.lang.String tagName,
Naming<java.lang.Object> attributes) |
void |
startElement(java.lang.String tagName,
java.lang.String... attributes) |
protected void |
undent()
Decreases indention level by one.
|
void |
writeAttribute(java.lang.String name,
java.lang.String value) |
void |
writeContent(java.lang.Object content) |
void |
writeContent(java.lang.Object content,
boolean newLine) |
void |
writeElement(java.lang.String tag,
double content) |
void |
writeElement(java.lang.String tag,
int content) |
void |
writeElement(java.lang.String tag,
java.lang.Object content) |
void |
writeEmptyElement(java.lang.String tagName,
Naming<java.lang.Object> attributes)
Writes an empty element tag (e.g.
|
void |
writeEmptyElement(java.lang.String tagName,
java.lang.String... attributes)
Writes an empty element tag (e.g.
|
void |
writeIterableContent(java.lang.String tagName,
java.lang.Iterable content) |
void |
writeRaw(java.lang.String text)
This writes text directly to the file, without escaping XML characters.
|
protected java.io.BufferedWriter outie
protected DynamicCharArray indentSpace
protected int indention
protected java.util.ArrayList<java.lang.String> stack
protected boolean droppingElementsWithoutContent
protected boolean emptyingElementsWithoutContent
public XmlBuilder(VfsFile outputFile) throws java.io.IOException
java.io.IOExceptionpublic XmlBuilder(java.io.File outputFile)
throws java.io.IOException
java.io.IOExceptionpublic XmlBuilder(java.io.Writer writer)
throws java.io.IOException
java.io.IOExceptionpublic XmlBuilder(java.io.Writer writer,
boolean printDoctype)
throws java.io.IOException
java.io.IOExceptionpublic void startElement(java.lang.String tagName)
throws java.io.IOException
java.io.IOExceptionpublic void startElement(java.lang.String tagName,
boolean newLine)
throws java.io.IOException
java.io.IOExceptionpublic void startElement(java.lang.String tagName,
java.lang.String... attributes)
throws java.io.IOException
java.io.IOExceptionpublic void startElement(java.lang.String tagName,
Naming<java.lang.Object> attributes)
throws java.io.IOException
java.io.IOExceptionpublic void endElement()
throws java.io.IOException
java.io.IOExceptionpublic void endElement(boolean newLine)
throws java.io.IOException
java.io.IOExceptionpublic void endElement(java.lang.String checkTagName)
throws java.io.IOException
java.io.IOExceptionpublic void endElement(java.lang.String checkTagName,
boolean newLine)
throws java.io.IOException
java.io.IOExceptionpublic void beginStartTag(java.lang.String tagName)
throws java.io.IOException
java.io.IOExceptionpublic void writeAttribute(java.lang.String name,
java.lang.String value)
throws java.io.IOException
java.io.IOExceptionpublic void endStartTag()
throws java.io.IOException
java.io.IOExceptionpublic void writeEmptyElement(java.lang.String tagName,
java.lang.String... attributes)
throws java.io.IOException
java.io.IOExceptionpublic void writeEmptyElement(java.lang.String tagName,
Naming<java.lang.Object> attributes)
throws java.io.IOException
java.io.IOExceptionpublic void writeElement(java.lang.String tag,
java.lang.Object content)
throws java.io.IOException
java.io.IOExceptionpublic void writeElement(java.lang.String tag,
double content)
throws java.io.IOException
java.io.IOExceptionpublic void writeElement(java.lang.String tag,
int content)
throws java.io.IOException
java.io.IOExceptionpublic void writeContent(java.lang.Object content)
throws java.io.IOException
java.io.IOExceptionpublic void writeContent(java.lang.Object content,
boolean newLine)
throws java.io.IOException
java.io.IOExceptionpublic void writeIterableContent(java.lang.String tagName,
java.lang.Iterable content)
throws java.io.IOException
java.io.IOExceptionpublic void close()
throws java.io.IOException
java.io.IOExceptionpublic void writeRaw(java.lang.String text)
throws java.io.IOException
java.io.IOExceptionprotected void newLine()
throws java.io.IOException
java.io.IOExceptionprotected void indent()
protected void undent()
public boolean isDroppingElementsWithoutContent()
public void setDroppingElementsWithoutContent(boolean droppingElementsWithoutContent)
droppingElementsWithoutContent - public boolean isEmptyingElementsWithoutContent()
public void setEmptyingElementsWithoutContent(boolean emptyingElementsWithoutContent)
emptyingElementsWithoutContent -