public class XMLWriter extends Object
Modifier and Type | Field and Description |
---|---|
protected StringBuilder |
buffer
Buffer.
|
static int |
CLOSING
Closing tag.
|
static int |
NO_CONTENT
Element with no content.
|
static int |
OPENING
Opening tag.
|
protected Writer |
writer
Writer.
|
Constructor and Description |
---|
XMLWriter()
New XML writer utility that will store its data in an internal buffer.
|
XMLWriter(Writer writer)
New XML writer utility that will store its data in an internal buffer
and can write it to the specified writer.
|
Modifier and Type | Method and Description |
---|---|
void |
sendData()
Send data and reinitializes buffer, if a writer has been specified.
|
String |
toString()
Retrieve generated XML.
|
void |
writeData(String data)
Write data.
|
void |
writeElement(String namespace,
String name,
int type)
Write an element.
|
void |
writeElement(String namespace,
String namespaceInfo,
String name,
int type)
Write an element.
|
void |
writeProperty(String namespace,
String name,
String value)
Write property to the XML.
|
void |
writeText(String text)
Write text.
|
void |
writeXMLHeader()
Write XML Header.
|
public static final int OPENING
public static final int CLOSING
public static final int NO_CONTENT
protected StringBuilder buffer
protected final Writer writer
public XMLWriter()
public XMLWriter(Writer writer)
See sendData()
writer
- The writer to usepublic String toString()
public void writeProperty(String namespace, String name, String value)
namespace
- Namespacename
- Property namevalue
- Property valuepublic void writeElement(String namespace, String name, int type)
name
- Element namenamespace
- Namespace abbreviationtype
- Element typepublic void writeElement(String namespace, String namespaceInfo, String name, int type)
namespace
- Namespace abbreviationnamespaceInfo
- Namespace infoname
- Element nametype
- Element typepublic void writeText(String text)
text
- Text to appendpublic void writeData(String data)
data
- Data to appendpublic void writeXMLHeader()
public void sendData() throws IOException
IOException
- Error writing XML dataCopyright © 2000-2016 Apache Software Foundation. All Rights Reserved.