|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.dbunit.util.xml.XmlWriter
public class XmlWriter
Makes writing XML much much easier. Improved from article
Constructor Summary | |
---|---|
XmlWriter(Writer writer)
Create an XmlWriter on top of an existing java.io.Writer. |
|
XmlWriter(Writer writer,
String encoding)
Create an XmlWriter on top of an existing java.io.Writer. |
Method Summary | |
---|---|
void |
close()
Close this writer. |
void |
enablePrettyPrint(boolean enable)
Turn pretty printing on or off. |
XmlWriter |
endElement()
End the current element. |
static void |
main(String[] args)
|
void |
setIndent(String indent)
Specify the string to prepend to a line for each level of indent. |
void |
setNewline(String newline)
Specify the string used to terminate each line when pretty printing. |
void |
setWriter(Writer writer,
String encoding)
Resets the handler to write a new text document. |
static void |
test1()
|
static void |
test2()
|
XmlWriter |
writeAttribute(String attr,
String value)
Write an attribute out for the current element. |
XmlWriter |
writeCData(String cdata)
Write out a chunk of CDATA. |
XmlWriter |
writeComment(String comment)
Write out a chunk of comment. |
XmlWriter |
writeDeclaration()
|
XmlWriter |
writeDoctype(String systemId,
String publicId)
|
XmlWriter |
writeElement(String name)
Begin to write out an element. |
XmlWriter |
writeElementWithText(String name,
String text)
A helper method. |
XmlWriter |
writeEmptyElement(String name)
A helper method. |
XmlWriter |
writeText(String text)
Output body text. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XmlWriter(Writer writer)
public XmlWriter(Writer writer, String encoding)
Method Detail |
---|
public void enablePrettyPrint(boolean enable)
enable
- true to enable, false to disable pretty printing.public void setIndent(String indent)
indent
- representing one level of indentation while pretty printing.public void setNewline(String newline)
newline
- representing the newline sequence when pretty printing.public XmlWriter writeElementWithText(String name, String text) throws IOException
name
- String name of tagtext
- String of text to go inside the tag
IOException
public XmlWriter writeEmptyElement(String name) throws IOException
name
- String name of tag
IOException
public XmlWriter writeElement(String name) throws IOException
name
- String name of tag
IOException
public XmlWriter writeAttribute(String attr, String value) throws IOException
attr
- name of attribute.value
- value of attribute.
IOException
public XmlWriter endElement() throws IOException
IOException
public void close() throws IOException
IOException
public XmlWriter writeText(String text) throws IOException
IOException
public XmlWriter writeCData(String cdata) throws IOException
cdata
- of CDATA text.
IOException
public XmlWriter writeComment(String comment) throws IOException
comment
- of text to comment.
IOException
public static void main(String[] args) throws IOException
IOException
public static void test1() throws IOException
IOException
public static void test2() throws IOException
IOException
public final void setWriter(Writer writer, String encoding)
writer
- XML text is written to this writer.encoding
- if non-null, and an XML declaration is written,
this is the name that will be used for the character encoding.
IllegalStateException
- if the current
document hasn't yet ended (with #endDocument
)public XmlWriter writeDeclaration() throws IOException
IOException
public XmlWriter writeDoctype(String systemId, String publicId) throws IOException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |