public class XMLWriter
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.Stack<java.lang.String> |
elementStack |
private static java.lang.String |
PROLOG
Standard XML prolog to add to the beginning of each XML document.
|
private boolean |
rootElement |
private java.io.Writer |
writer
The writer to which the XML document created by this writer will be written.
|
private java.lang.String |
xmlns
Optional XML namespace attribute value to include in the root element.
|
Constructor and Description |
---|
XMLWriter(java.io.Writer w)
Creates a new XMLWriter, ready to write an XML document to the specified
writer.
|
XMLWriter(java.io.Writer w,
java.lang.String xmlns)
Creates a new XMLWriter, ready to write an XML document to the specified
writer.
|
Modifier and Type | Method and Description |
---|---|
private void |
append(java.lang.String s) |
XMLWriter |
endElement()
Closes the last opened element at the current position in the in-progress
XML document.
|
private java.lang.String |
escapeXMLEntities(java.lang.String s) |
XMLWriter |
startElement(java.lang.String element)
Starts a new element with the specified name at the current position in
the in-progress XML document.
|
XMLWriter |
value(java.nio.ByteBuffer b)
Adds the specified value as Base64 encoded text to the current position of the in
progress XML document.
|
XMLWriter |
value(java.util.Date date)
Adds the specified date as text to the current position of the
in-progress XML document.
|
XMLWriter |
value(java.lang.Object obj)
Adds the string representation of the specified object to the current
position of the in progress XML document.
|
XMLWriter |
value(java.lang.String s)
Adds the specified value as text to the current position of the in
progress XML document.
|
private static final java.lang.String PROLOG
private final java.io.Writer writer
private final java.lang.String xmlns
private java.util.Stack<java.lang.String> elementStack
private boolean rootElement
public XMLWriter(java.io.Writer w)
w
- The writer this XMLWriter will write to.public XMLWriter(java.io.Writer w, java.lang.String xmlns)
w
- The writer this XMLWriter will write to.xmlns
- The XML namespace to include in the xmlns attribute of the
root element.public XMLWriter startElement(java.lang.String element)
element
- The name of the new element.public XMLWriter endElement()
public XMLWriter value(java.lang.String s)
s
- The text to add to the XML document.public XMLWriter value(java.nio.ByteBuffer b)
b
- The binary data to add to the XML document.public XMLWriter value(java.util.Date date)
date
- The date to add to the XML document.public XMLWriter value(java.lang.Object obj)
obj
- The object to translate to a string and add to the XML
document.private void append(java.lang.String s)
private java.lang.String escapeXMLEntities(java.lang.String s)