Package com.sun.javatest.util
Class XMLWriter
java.lang.Object
com.sun.javatest.util.XMLWriter
A class to facilitate writing XML via a stream.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate an XMLWriter object, using a default header.XMLWriter
(Writer out, I18NResourceBundle i18n) Create an XMLWriter object, using a specified bundle for l0calizing messages.Create an XMLWriter object, using a specified doctype header.XMLWriter
(Writer out, String docType, I18NResourceBundle i18n) Create an XMLWriter object, using a specified doctype header and using a specified bundle for localizing messages. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the stream, and the underlying output stream.void
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
Set the resource bundle to be used for localizing messages.void
Start an XML tag.void
write
(I18NResourceBundle i18n, String key) Write a localized message, using a specified resource bundle.void
write
(I18NResourceBundle i18n, String key, Object arg) Write a localized message, using a specified resource bundle.void
write
(I18NResourceBundle i18n, String key, Object... args) Write a localized message, using a specified resource bundle.void
Write body text, escaping it as necessary.void
Write an attribute for a tag.void
writeDate
(long millis) Write a formatted date.void
Write a formatted date surrounded by a markup tag.void
Write a formatted date surrounded by a markup tag.void
Write a formatted date.void
Write a localized message, using the default resource bundle.void
Write a localized message, using the default resource bundle.void
Write a localized message, using the default resource bundle.void
Write a line of text, followed by a newline.
-
Constructor Details
-
XMLWriter
Create an XMLWriter object, using a default header.- Parameters:
out
- a Writer to which to write the generated XML- Throws:
IOException
- if there is a problem writing to the underlying stream
-
XMLWriter
Create an XMLWriter object, using a specified doctype header.- Parameters:
out
- a Writer to which to write the generated XMLdocType
- a string containing a doctype header for the XML to be generated- Throws:
IOException
- if there is a problem writing to the underlying stream
-
XMLWriter
Create an XMLWriter object, using a specified bundle for l0calizing messages.- Parameters:
out
- a Writer to which to write the generated XMLi18n
- a resource bundle to use to localize messages- Throws:
IOException
- if there is a problem writing to the underlying stream
-
XMLWriter
Create an XMLWriter object, using a specified doctype header and using a specified bundle for localizing messages.- Parameters:
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 messages- Throws:
IOException
- if there is a problem writing to the underlying stream
-
-
Method Details
-
setI18NResourceBundle
Set the resource bundle to be used for localizing messages.- Parameters:
i18n
- the resource bundle to be used for localizing messages
-
flush
Flush the stream, and the underlying output stream.- Throws:
IOException
- if there is a problem writing to the underlying stream
-
close
Close the stream, and the underlying output stream.- Throws:
IOException
- if there is a problem closing the underlying stream
-
newLine
Write a newline to the underlying output stream.- Throws:
IOException
- if there is a problem closing the underlying stream
-
startTag
Start an XML tag. If a prior tag has been started, it will be closed first. Once a tag has been opened, attributes for the tag may be written out, followed by body content before finally ending the tag.- Parameters:
tag
- the tag to be started- Throws:
IOException
- if there is a problem closing the underlying stream- See Also:
-
endTag
Finish an XML tag. It is expected that a call to endTag will match a corresponding earlier call to startTag, but there is no formal check for this.- Parameters:
tag
- the tag to be closed.- Throws:
IOException
- if there is a problem closing the underlying stream
-
writeAttr
Write an attribute for a tag. A tag must previously have been started. All tag attributes must be written before any body text is written. The value will be quoted if necessary when writing it to the underlying stream. No check is made that the attribute is valid for the current tag.- Parameters:
name
- the name of the attribute to be writtenvalue
- the value of the attribute to be written- Throws:
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 writteAttrIOException
- if there is a problem closing the underlying stream
-
writeLine
Write a line of text, followed by a newline. The text will be escaped as necessary.- Parameters:
text
- the text to be written.- Throws:
IOException
- if there is a problem closing the underlying stream
-
writeDate
Write a formatted date.- Parameters:
millis
- date represented in milliseconds- Throws:
IOException
- if a exception occurs during writing- See Also:
-
writeDate
Write a formatted date surrounded by a markup tag.- Parameters:
tag
- tag to open and close before and after the date is insertedmillis
- date represented in milliseconds- Throws:
IOException
- if a exception occurs during writing- See Also:
-
writeDate
Write a formatted date.- Parameters:
date
- the date to print- Throws:
IOException
- if a exception occurs during writing
-
writeDate
Write a formatted date surrounded by a markup tag.- Parameters:
tag
- tag to open and close before and after the date is inserteddate
- the date to print- Throws:
IOException
- if a exception occurs during writing- See Also:
-
write
Write body text, escaping it as necessary. If this call follows a call of startTag, the open tag will be closed -- meaning that no more attributes can be written until another tag is started.- Parameters:
text
- the text to be written- Throws:
IOException
- if there is a problem closing the underlying stream
-
write
Write a localized message, using a specified resource bundle.- Parameters:
i18n
- the resource bundle used to localize the messagekey
- the key for the message to be localized- Throws:
IOException
- if there is a problem closing the underlying stream
-
write
Write a localized message, using a specified resource bundle.- Parameters:
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 message- Throws:
IOException
- if there is a problem closing the underlying stream
-
write
Write a localized message, using a specified resource bundle.- Parameters:
i18n
- the resource bundle used to localize the messagekey
- the key for the message to be localizedargs
- arguments to be formatted into the localized message- Throws:
IOException
- if there is a problem closing the underlying stream
-
writeI18N
Write a localized message, using the default resource bundle.- Parameters:
key
- the key for the message to be localized- Throws:
IOException
- if there is a problem closing the underlying stream
-
writeI18N
Write a localized message, using the default resource bundle.- Parameters:
key
- the key for the message to be localizedarg
- an argument to be formatted into the localized message- Throws:
IOException
- if there is a problem closing the underlying stream
-
writeI18N
Write a localized message, using the default resource bundle.- Parameters:
key
- the key for the message to be localizedargs
- arguments to be formatted into the localized message- Throws:
IOException
- if there is a problem closing the underlying stream
-