public class XmlWriter
extends java.io.PrintWriter
Modifier and Type | Class and Description |
---|---|
static class |
XmlWriter.Html |
static class |
XmlWriter.Strategy |
static class |
XmlWriter.Xhtml
If content model is empty,
|
static class |
XmlWriter.Xml |
Modifier and Type | Field and Description |
---|---|
static XmlWriter.Strategy |
HTML |
static XmlWriter.Strategy |
XHTML |
static XmlWriter.Strategy |
XML |
Constructor and Description |
---|
XmlWriter(java.io.Writer out) |
Modifier and Type | Method and Description |
---|---|
void |
endBlockElement(java.lang.String name)
End an element where the opening tag is on it's own line, the content
is on it's own line, and the closing tag is on it's own line.
|
void |
endElement(java.lang.String name)
End an element.
|
void |
endLineElement(java.lang.String name)
End an element where the opening tag, content, and closing tags are on
a single line of their own.
|
void |
flush()
Close an open element (if any), then flush the underlying
writer.
|
java.lang.String |
getCharacterEncoding() |
java.lang.String |
getContentType() |
boolean |
isIndenting() |
boolean |
isNewLine() |
void |
println() |
void |
setCharacterEncoding(java.lang.String characterEncoding)
Default is "UTF-8".
|
void |
setContentType(java.lang.String contentType)
Default is "text/xml".
|
void |
setIndenting(boolean isIndenting) |
void |
setStrategy(XmlWriter.Strategy strategy) |
boolean |
softPrintln() |
void |
startBlockElement(java.lang.String name)
Start an element where the opening tag is on it's own line, the content
is on it's own line, and the closing tag is on it's own line.
|
void |
startElement(java.lang.String name)
Start an element.
|
void |
startLineElement(java.lang.String name)
Start an element where the opening tag, content, and closing tags are on
a single line of their own.
|
void |
write(char[] buf) |
void |
write(char[] buf,
int off,
int len) |
void |
write(int ch) |
void |
write(java.lang.String s) |
void |
write(java.lang.String s,
int off,
int len) |
void |
writeAttribute(java.lang.String name,
java.lang.Object... values)
Write an attribute with multiple values, separated by space, if a value
is null nothing is written.
|
void |
writeAttribute(java.lang.String name,
java.lang.Object value)
Write an attribute with a value, if value is null nothing is written.
|
void |
writeBlockElement(java.lang.String name)
Convenience method, same as doing a startBlockElement() and then immediately
doing an endBlockElement().
|
void |
writeBlockElement(java.lang.String name,
java.lang.Object text)
Convenience method, same as doing a startBlockElement(), writeText(text),
endBlockElement().
|
void |
writeComment(java.lang.String comment)
Close an open element (if any), then write with escaping as needed.
|
void |
writeElement(java.lang.String name)
Convenience method, same as doing a startElement() and then immediately
doing an endElement().
|
void |
writeElement(java.lang.String name,
java.lang.Object text)
Convenience method, same as doing a startElement(), writeText(text),
endElement().
|
void |
writeLineElement(java.lang.String name)
Convenience method, same as doing a startLineElement() and then immediately
doing an endLineElement().
|
void |
writeLineElement(java.lang.String name,
java.lang.Object text)
Convenience method, same as doing a startLineElement(), writeText(text),
endLineElement().
|
void |
writeText(char ch)
Close an open element (if any), then write with escaping as needed.
|
void |
writeText(char[] buf)
Close an open element (if any), then write with escaping as needed.
|
void |
writeText(char[] buf,
int offset,
int length)
Close an open element (if any), then write with escaping as needed.
|
void |
writeText(java.lang.Object obj)
Close an open element (if any), then write object.toString(), with escaping
as needed.
|
public static final XmlWriter.Strategy XML
public static final XmlWriter.Strategy XHTML
public static final XmlWriter.Strategy HTML
public java.lang.String getContentType()
public void setContentType(java.lang.String contentType)
public void setStrategy(XmlWriter.Strategy strategy)
public void setIndenting(boolean isIndenting)
public boolean isIndenting()
public void setCharacterEncoding(java.lang.String characterEncoding)
public java.lang.String getCharacterEncoding()
public void startElement(java.lang.String name)
public void endElement(java.lang.String name)
public void startBlockElement(java.lang.String name)
public void endBlockElement(java.lang.String name)
public void startLineElement(java.lang.String name)
public void endLineElement(java.lang.String name)
public void writeElement(java.lang.String name)
public void writeLineElement(java.lang.String name)
public void writeBlockElement(java.lang.String name)
public void writeElement(java.lang.String name, java.lang.Object text)
public void writeLineElement(java.lang.String name, java.lang.Object text)
public void writeBlockElement(java.lang.String name, java.lang.Object text)
public void writeAttribute(java.lang.String name, java.lang.Object value)
java.lang.IllegalStateException
- if the is no element is openpublic void writeAttribute(java.lang.String name, java.lang.Object... values)
java.lang.IllegalStateException
- if the is no element is openpublic void writeText(char ch)
public void writeText(char[] buf)
public void writeText(char[] buf, int offset, int length)
public void writeText(java.lang.Object obj)
public void writeComment(java.lang.String comment)
public void flush()
flush
in interface java.io.Flushable
flush
in class java.io.PrintWriter
public void println()
println
in class java.io.PrintWriter
public boolean isNewLine()
public boolean softPrintln()
public void write(int ch)
write
in class java.io.PrintWriter
public void write(char[] buf, int off, int len)
write
in class java.io.PrintWriter
public void write(char[] buf)
write
in class java.io.PrintWriter
public void write(java.lang.String s, int off, int len)
write
in class java.io.PrintWriter
public void write(java.lang.String s)
write
in class java.io.PrintWriter