public class XmlWriter extends Object implements AutoCloseable
| Modifier and Type | Class and Description |
|---|---|
static interface |
XmlWriter.DoubleFormater
Functional interface for formatting double values in XML output.
|
| Modifier and Type | Field and Description |
|---|---|
(package private) static String |
INDENT_STR |
| Constructor and Description |
|---|
XmlWriter(OutputStream stream)
Creates XmlWriter with the specified
OutputStream to send XML code to. |
XmlWriter(OutputStream stream,
boolean autoFlush)
Creates XmlWriter with the specified output stream to send XML code to.
|
XmlWriter(PrintWriter stream)
Creates XmlWriter with the specified
PrintWriter to send XML code to. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
closeTag()
Closes the corresponding XML tag
|
void |
flush()
Flushes the output stream
|
String |
formatTimestamp(long timestamp)
Formats a timestamp using the configured
DateTimeFormatter. |
void |
startTag(String tag)
Opens XML tag
|
XmlWriter |
withDoubleFormatter(XmlWriter.DoubleFormater doubleFormatter)
Return a new
XmlWriter that will format time stamp using this ZoneId |
XmlWriter |
withTimeZone(java.time.ZoneId zid)
Return a new
XmlWriter that will format time stamp as ISO 8601 with this explicit
time zone ZoneId |
void |
writeComment(long timestamp)
Writes a timestamp using the configured
DateTimeFormatter as an XML comment to output
stream. |
void |
writeComment(Object comment)
Writes XML comment to output stream
|
void |
writeTag(String tag,
boolean value)
Writes <tag>value</tag> to output stream
|
void |
writeTag(String tag,
Color value)
Writes <tag>value</tag> to output stream
|
void |
writeTag(String tag,
double value)
Writes <tag>value</tag> to output stream
|
void |
writeTag(String tag,
double value,
String nanString)
Writes <tag>value</tag> to output stream
|
void |
writeTag(String tag,
File value)
Writes <tag>value</tag> to output stream
|
void |
writeTag(String tag,
Font value)
Writes <tag>value</tag> to output stream
|
void |
writeTag(String tag,
int value)
Writes <tag>value</tag> to output stream
|
void |
writeTag(String tag,
long value)
Writes <tag>value</tag> to output stream
|
void |
writeTag(String tag,
Object value)
Writes <tag>value</tag> to output stream
|
static final String INDENT_STR
public XmlWriter(OutputStream stream)
OutputStream to send XML code to.stream - OutputStream which receives XML codepublic XmlWriter(OutputStream stream, boolean autoFlush)
stream - Output stream which receives XML codeautoFlush - is the stream to be flushed automaticallypublic XmlWriter(PrintWriter stream)
PrintWriter to send XML code to.stream - PrintWriter which receives XML codepublic void close()
close in interface AutoCloseablepublic void closeTag()
public void flush()
public String formatTimestamp(long timestamp)
DateTimeFormatter.timestamp - the timestamp to formatpublic void startTag(String tag)
tag - XML tag namepublic XmlWriter withDoubleFormatter(XmlWriter.DoubleFormater doubleFormatter)
XmlWriter that will format time stamp using this ZoneIddoubleFormatter - public XmlWriter withTimeZone(java.time.ZoneId zid)
XmlWriter that will format time stamp as ISO 8601 with this explicit
time zone ZoneIdzid - public void writeComment(long timestamp)
DateTimeFormatter as an XML comment to output
stream.timestamp - the timestamp to writepublic void writeComment(Object comment)
comment - comment stringpublic void writeTag(String tag, boolean value)
tag - XML tag namevalue - value to be placed between <tag> and </tag>
public void writeTag(String tag, Color value)
tag - XML tag namevalue - value to be placed between <tag> and </tag>
public void writeTag(String tag, double value)
tag - XML tag namevalue - value to be placed between <tag> and </tag>
public void writeTag(String tag, double value, String nanString)
tag - XML tag namevalue - value to be placed between <tag> and </tag>
nanString - a String object.public void writeTag(String tag, File value)
tag - XML tag namevalue - value to be placed between <tag> and </tag>
public void writeTag(String tag, Font value)
tag - XML tag namevalue - value to be placed between <tag> and </tag>
public void writeTag(String tag, int value)
tag - XML tag namevalue - value to be placed between <tag> and </tag>
public void writeTag(String tag, long value)
tag - XML tag namevalue - value to be placed between <tag> and </tag>