StringWriter writer = new StringWriter();
XmlWriter xml = new XmlWriter(writer);
xml.element("meow")
.attribute("moo", "cow")
.element("child")
.attribute("moo", "cow")
.element("child")
.attribute("moo", "cow")
.text("XML is like violence. If it doesn't solve your problem, you're not using enough of it.")
.pop()
.pop()
.pop();
System.out.println(writer);
| Modifier and Type | Field and Description |
|---|---|
| private String | |
| public int | |
| private boolean | |
| private final Array | |
| private final Writer |
| Modifier and Type | Method and Description |
|---|---|
| public XmlWriter | |
| public void | close()
Implements abstract java. Implements java. Calls |
| public XmlWriter | |
| public XmlWriter | |
| public void | flush()
Implements abstract java. Implements java. Flushes the stream. |
| private void | |
| public XmlWriter | |
| private boolean | |
| public XmlWriter | |
| public void | write(char[] cbuf, int off, int len)
Implements abstract java. Writes a portion of an array of characters. |
| currentElement | back to summary |
|---|---|
| private String currentElement | |
| indent | back to summary |
|---|---|
| public int indent | |
| indentNextClose | back to summary |
|---|---|
| private boolean indentNextClose | |
| stack | back to summary |
|---|---|
| private final Array<String> stack | |
| writer | back to summary |
|---|---|
| private final Writer writer | |
| XmlWriter | back to summary |
|---|---|
| public XmlWriter(Writer writer) | |
| attribute | back to summary |
|---|---|
| public XmlWriter attribute(String name, Object value) throws IOException | |
| close | back to summary |
|---|---|
| public void close() throws IOException Implements abstract java. Implements java. Calls
| |
| element | back to summary |
|---|---|
| public XmlWriter element(String name) throws IOException | |
| element | back to summary |
|---|---|
| public XmlWriter element(String name, Object text) throws IOException | |
| flush | back to summary |
|---|---|
| public void flush() throws IOException Implements abstract java. Implements java. Doc from java. Flushes the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams. If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.
| |
| indent | back to summary |
|---|---|
| private void indent() throws IOException | |
| pop | back to summary |
|---|---|
| public XmlWriter pop() throws IOException | |
| startElementContent | back to summary |
|---|---|
| private boolean startElementContent() throws IOException | |
| text | back to summary |
|---|---|
| public XmlWriter text(Object text) throws IOException | |
| write | back to summary |
|---|---|
| public void write(char[] cbuf, int off, int len) throws IOException Implements abstract java. Doc from java. Writes a portion of an array of characters.
| |