public class XMLWriter
extends java.lang.Object
Constructor and Description |
---|
XMLWriter(java.io.Writer out)
Create an XMLWriter object, using a default header.
|
XMLWriter(java.io.Writer out,
I18NResourceBundle i18n)
Create an XMLWriter object, using a specified bundle for l0calizing messages.
|
XMLWriter(java.io.Writer out,
java.lang.String docType)
Create an XMLWriter object, using a specified doctype header.
|
XMLWriter(java.io.Writer out,
java.lang.String docType,
I18NResourceBundle i18n)
Create an XMLWriter object, using a specified doctype header and
using a specified bundle for localizing messages.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the stream, and the underlying output stream.
|
void |
endTag(java.lang.String tag)
Finish an XML tag.
|
void |
flush()
Flush the stream, and the underlying output stream.
|
void |
newLine()
Write a newline to the underlying output stream.
|
void |
setI18NResourceBundle(I18NResourceBundle i18n)
Set the resource bundle to be used for localizing messages.
|
void |
startTag(java.lang.String tag)
Start an XML tag.
|
void |
write(I18NResourceBundle i18n,
java.lang.String key)
Write a localized message, using a specified resource bundle.
|
void |
write(I18NResourceBundle i18n,
java.lang.String key,
java.lang.Object arg)
Write a localized message, using a specified resource bundle.
|
void |
write(I18NResourceBundle i18n,
java.lang.String key,
java.lang.Object[] args)
Write a localized message, using a specified resource bundle.
|
void |
write(java.lang.String text)
Write body text, escaping it as necessary.
|
void |
writeAttr(java.lang.String name,
java.lang.String value)
Write an attribute for a tag.
|
void |
writeDate(java.util.Date date)
Write a formatted date.
|
void |
writeDate(long millis)
Write a formatted date.
|
void |
writeDate(java.lang.String tag,
java.util.Date date)
Write a formatted date surrounded by a markup tag.
|
void |
writeDate(java.lang.String tag,
long millis)
Write a formatted date surrounded by a markup tag.
|
void |
writeI18N(java.lang.String key)
Write a localized message, using the default resource bundle.
|
void |
writeI18N(java.lang.String key,
java.lang.Object arg)
Write a localized message, using the default resource bundle.
|
void |
writeI18N(java.lang.String key,
java.lang.Object[] args)
Write a localized message, using the default resource bundle.
|
void |
writeLine(java.lang.String text)
Write a line of text, followed by a newline.
|
public XMLWriter(java.io.Writer out) throws java.io.IOException
out
- a Writer to which to write the generated XMLjava.io.IOException
- if there is a problem writing to the underlying streampublic XMLWriter(java.io.Writer out, java.lang.String docType) throws java.io.IOException
out
- a Writer to which to write the generated XMLdocType
- a string containing a doctype header for the XML to be generatedjava.io.IOException
- if there is a problem writing to the underlying streampublic XMLWriter(java.io.Writer out, I18NResourceBundle i18n) throws java.io.IOException
out
- a Writer to which to write the generated XMLi18n
- a resource bundle to use to localize messagesjava.io.IOException
- if there is a problem writing to the underlying streampublic XMLWriter(java.io.Writer out, java.lang.String docType, I18NResourceBundle i18n) throws java.io.IOException
out
- a Writer to which to write the generated XMLdocType
- a string containing a doctype header for the XML to be generatedi18n
- a resource bundle to use to localize messagesjava.io.IOException
- if there is a problem writing to the underlying streampublic void setI18NResourceBundle(I18NResourceBundle i18n)
i18n
- the resource bundle to be used for localizing messagespublic void flush() throws java.io.IOException
java.io.IOException
- if there is a problem writing to the underlying streampublic void close() throws java.io.IOException
java.io.IOException
- if there is a problem closing the underlying streampublic void newLine() throws java.io.IOException
java.io.IOException
- if there is a problem closing the underlying streampublic void startTag(java.lang.String tag) throws java.io.IOException
tag
- the tag to be startedjava.io.IOException
- if there is a problem closing the underlying streamwriteAttr(java.lang.String, java.lang.String)
,
write(java.lang.String)
,
endTag(java.lang.String)
public void endTag(java.lang.String tag) throws java.io.IOException
tag
- the tag to be closed.java.io.IOException
- if there is a problem closing the underlying streampublic void writeAttr(java.lang.String name, java.lang.String value) throws java.io.IOException
name
- the name of the attribute to be writtenvalue
- the value of the attribute to be writtenjava.lang.IllegalStateException
- if the stream is not in a state to
write attributes -- e.g. if this call does not follow startTag or other
calls of writteAttrjava.io.IOException
- if there is a problem closing the underlying streampublic void writeLine(java.lang.String text) throws java.io.IOException
text
- the text to be written.java.io.IOException
- if there is a problem closing the underlying streampublic void writeDate(long millis) throws java.io.IOException
millis
- date represented in millisecondsjava.io.IOException
- if a exception occurs during writingDate
public void writeDate(java.lang.String tag, long millis) throws java.io.IOException
tag
- tag to open and close before and after the date is insertedmillis
- date represented in millisecondsjava.io.IOException
- if a exception occurs during writingDate
public void writeDate(java.util.Date date) throws java.io.IOException
date
- the date to printjava.io.IOException
- if a exception occurs during writingpublic void writeDate(java.lang.String tag, java.util.Date date) throws java.io.IOException
tag
- tag to open and close before and after the date is inserteddate
- the date to printjava.io.IOException
- if a exception occurs during writingDate
public void write(java.lang.String text) throws java.io.IOException
text
- the text to be writtenjava.io.IOException
- if there is a problem closing the underlying streampublic void write(I18NResourceBundle i18n, java.lang.String key) throws java.io.IOException
i18n
- the resource bundle used to localize the messagekey
- the key for the message to be localizedjava.io.IOException
- if there is a problem closing the underlying streampublic void write(I18NResourceBundle i18n, java.lang.String key, java.lang.Object arg) throws java.io.IOException
i18n
- the resource bundle used to localize the messagekey
- the key for the message to be localizedarg
- an argument to be formatted into the localized messagejava.io.IOException
- if there is a problem closing the underlying streampublic void write(I18NResourceBundle i18n, java.lang.String key, java.lang.Object[] args) throws java.io.IOException
i18n
- the resource bundle used to localize the messagekey
- the key for the message to be localizedargs
- arguments to be formatted into the localized messagejava.io.IOException
- if there is a problem closing the underlying streampublic void writeI18N(java.lang.String key) throws java.io.IOException
key
- the key for the message to be localizedjava.io.IOException
- if there is a problem closing the underlying streampublic void writeI18N(java.lang.String key, java.lang.Object arg) throws java.io.IOException
key
- the key for the message to be localizedarg
- an argument to be formatted into the localized messagejava.io.IOException
- if there is a problem closing the underlying streampublic void writeI18N(java.lang.String key, java.lang.Object[] args) throws java.io.IOException
key
- the key for the message to be localizedargs
- arguments to be formatted into the localized messagejava.io.IOException
- if there is a problem closing the underlying streamCopyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.