Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.javatest.util
Class HTMLWriter

    java.lang.Object
      com.sun.javatest.util.HTMLWriter

    public class HTMLWriter

extends java.lang.Object

A class to facilitate writing HTML via a stream.

Field Summary
`static java.lang.String` | `A` The HTML "a" tag.
`static java.lang.String` | `ALIGN` The HTML "align" attribute.
`static java.lang.String` | `B` The HTML "b" tag.
`static java.lang.String` | `BODY` The HTML "body" tag.
`static java.lang.String` | `BORDER` The HTML "border" attribute.
`static java.lang.String` | `BR` The HTML "br" tag.
`static java.lang.String` | `CLASSID` The HTML "classid" attribute.
`static java.lang.String` | `CODE` The HTML "code" tag.
`static java.lang.String` | `COL` The HTML "col" attribute value.
`static java.lang.String` | `COLOR` The HTML "color" attribte.
`static java.lang.String` | `FONT` The HTML "font" tag.
`static java.lang.String` | `H1` The HTML "h1" tag.
`static java.lang.String` | `H2` The HTML "h2" tag.
`static java.lang.String` | `H3` The HTML "h3" tag.
`static java.lang.String` | `H4` The HTML "h4" tag.
`static java.lang.String` | `HEAD` The HTML "head" tag.
`static java.lang.String` | `HR` The HTML "hr" tag.
`static java.lang.String` | `HREF` The HTML "href" attribute.
`static java.lang.String` | `HTML` The HTML "html" tag.
`static java.lang.String` | `I` The HTML "i" tag.
`static java.lang.String` | `IMAGE` The HTML "image" tag.
`static java.lang.String` | `LEFT` The HTML "left" attribute value.
`static java.lang.String` | `LI` The HTML "li" tag.
`static java.lang.String` | `LINK` The HTML "link" tag.
`static java.lang.String` | `NAME` The HTML "name" attribute.
`static java.lang.String` | `OBJECT` The HTML "object" tag.
`static java.lang.String` | `P` The HTML "param" tag.
`static java.lang.String` | `PARAM` The HTML "p" tag.
`static java.lang.String` | `REL` The HTML "rel" attribute value.
`static java.lang.String` | `RIGHT` The HTML "right" attribute value.
`static java.lang.String` | `ROW` The HTML "row" attribute value.
`static java.lang.String` | `SCOPE` The HTML "scope" attribute.
`static java.lang.String` | `SMALL` The HTML "small" tag.
`static java.lang.String` | `SRC` The HTML "src" attribute.
`static java.lang.String` | `STYLE` The HTML "style" attribute.
`static java.lang.String` | `TABLE` The HTML "table" tag.
`static java.lang.String` | `TD` The HTML "td" tag.
`static java.lang.String` | `TH` The HTML "th" tag.
`static java.lang.String` | `TITLE` The HTML "title"attribute.
`static java.lang.String` | `TOP` The HTML "top" attribute value.
`static java.lang.String` | `TR` The HTML "tr" tag.
`static java.lang.String` | `TYPE` The HTML "type" attribute.
`static java.lang.String` | `UL` The HTML "ul" tag.
`static java.lang.String` | `VALIGN` The HTML "valign" attribute.
`static java.lang.String` | `VALUE` The HTML "value" attribute.

Constructor Summary
`HTMLWriter(java.io.Writer out)` Create an HTMLWriter object, using a default doctype for HTML 3.2.
`HTMLWriter(java.io.Writer out, I18NResourceBundle i18n)` Create an HTMLWriter object, using a specified bundle for l0calizing messages.
`HTMLWriter(java.io.Writer out, java.lang.String docType)` Create an HTMLWriter object, using a specifed doctype header.
`HTMLWriter(java.io.Writer out, java.lang.String docType, I18NResourceBundle i18n)` Create an HTMLWriter object, using a specifed doctype header and using a specified bundle for l0calizing messages.

Method Summary
`void` | `close()` Close the stream, and the underlying output stream.
`void` | `endEmptyTag(java.lang.String tag)` Finish an empty element tag, such as a META, BASE or LINK tag.
`void` | `endTag(java.lang.String tag)` Finish an HTML 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 reource bundle to be used for localizing messages.
`void` | `startTag(java.lang.String tag)` Start an HTML 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, int value)` Write an attribute for a tag.
`void` | `writeAttr(java.lang.String name, java.lang.String value)` Write an attribute for a tag.
`void` | `writeEntity(java.lang.String entity)` Write a basic HTML entity, such as or { .
`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` | `writeImage(java.lang.String imagePath)` Write an image tag, using a specified path for the image source attribute.
`void` | `writeImage(java.net.URL imageURL)` Write an image tag, using a specified path for the image source attribute.
`void` | `writeLine(java.lang.String text)` Write a line of text, followed by a newline.
`void` | `writeLink(java.io.File file)` Write a hypertext link.
`void` | `writeLink(java.io.File file, java.lang.String body)` Write a hypertext link.
`void` | `writeLink(java.lang.String anchor, java.lang.String body)` Write a hypertext link.
`void` | `writeLink(java.net.URL url, java.lang.String body)` Write a hypertext link.
`void` | `writeLinkDestination(java.lang.String anchor, java.lang.String body)` Write the destination marker for a hypertext link.
`void` | `writeParam(java.lang.String name, java.lang.String value)` Write a parameter tag.
`void` | `writeStyleAttr(java.lang.String value)` Write a style attribute.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### A

    public static final java.lang.String A

  The HTML "a" tag.

  See Also:
    Constant Field Values

### ALIGN

    public static final java.lang.String ALIGN

  The HTML "align" attribute.

  See Also:
    Constant Field Values

### B

    public static final java.lang.String B

  The HTML "b" tag.

  See Also:
    Constant Field Values

### BODY

    public static final java.lang.String BODY

  The HTML "body" tag.

  See Also:
    Constant Field Values

### BORDER

    public static final java.lang.String BORDER

  The HTML "border" attribute.

  See Also:
    Constant Field Values

### BR

    public static final java.lang.String BR

  The HTML "br" tag.

  See Also:
    Constant Field Values

### CLASSID

    public static final java.lang.String CLASSID

  The HTML "classid" attribute.

  See Also:
    Constant Field Values

### CODE

    public static final java.lang.String CODE

  The HTML "code" tag.

  See Also:
    Constant Field Values

### COLOR

    public static final java.lang.String COLOR

  The HTML "color" attribte.

  See Also:
    Constant Field Values

### COL

    public static final java.lang.String COL

  The HTML "col" attribute value.

  See Also:
    Constant Field Values

### FONT

    public static final java.lang.String FONT

  The HTML "font" tag.

  See Also:
    Constant Field Values

### H1

    public static final java.lang.String H1

  The HTML "h1" tag.

  See Also:
    Constant Field Values

### H2

    public static final java.lang.String H2

  The HTML "h2" tag.

  See Also:
    Constant Field Values

### H3

    public static final java.lang.String H3

  The HTML "h3" tag.

  See Also:
    Constant Field Values

### H4

    public static final java.lang.String H4

  The HTML "h4" tag.

  See Also:
    Constant Field Values

### HEAD

    public static final java.lang.String HEAD

  The HTML "head" tag.

  See Also:
    Constant Field Values

### HREF

    public static final java.lang.String HREF

  The HTML "href" attribute.

  See Also:
    Constant Field Values

### HTML

    public static final java.lang.String HTML

  The HTML "html" tag.

  See Also:
    Constant Field Values

### HR

    public static final java.lang.String HR

  The HTML "hr" tag.

  See Also:
    Constant Field Values

### I

    public static final java.lang.String I

  The HTML "i" tag.

  See Also:
    Constant Field Values

### IMAGE

    public static final java.lang.String IMAGE

  The HTML "image" tag.

  See Also:
    Constant Field Values

### LEFT

    public static final java.lang.String LEFT

  The HTML "left" attribute value.

  See Also:
    Constant Field Values

### LI

    public static final java.lang.String LI

  The HTML "li" tag.

  See Also:
    Constant Field Values

### LINK

    public static final java.lang.String LINK

  The HTML "link" tag.

  See Also:
    Constant Field Values

### NAME

    public static final java.lang.String NAME

  The HTML "name" attribute.

  See Also:
    Constant Field Values

### OBJECT

    public static final java.lang.String OBJECT

  The HTML "object" tag.

  See Also:
    Constant Field Values

### PARAM

    public static final java.lang.String PARAM

  The HTML "p" tag.

  See Also:
    Constant Field Values

### P

    public static final java.lang.String P

  The HTML "param" tag.

  See Also:
    Constant Field Values

### REL

    public static final java.lang.String REL

  The HTML "rel" attribute value.

  See Also:
    Constant Field Values

### RIGHT

    public static final java.lang.String RIGHT

  The HTML "right" attribute value.

  See Also:
    Constant Field Values

### ROW

    public static final java.lang.String ROW

  The HTML "row" attribute value.

  See Also:
    Constant Field Values

### SMALL

    public static final java.lang.String SMALL

  The HTML "small" tag.

  See Also:
    Constant Field Values

### SRC

    public static final java.lang.String SRC

  The HTML "src" attribute.

  See Also:
    Constant Field Values

### SCOPE

    public static final java.lang.String SCOPE

  The HTML "scope" attribute.

  See Also:
    Constant Field Values

### STYLE

    public static final java.lang.String STYLE

  The HTML "style" attribute.

  See Also:
    Constant Field Values

### TABLE

    public static final java.lang.String TABLE

  The HTML "table" tag.

  See Also:
    Constant Field Values

### TD

    public static final java.lang.String TD

  The HTML "td" tag.

  See Also:
    Constant Field Values

### TITLE

    public static final java.lang.String TITLE

  The HTML "title"attribute.

  See Also:
    Constant Field Values

### TH

    public static final java.lang.String TH

  The HTML "th" tag.

  See Also:
    Constant Field Values

### TOP

    public static final java.lang.String TOP

  The HTML "top" attribute value.

  See Also:
    Constant Field Values

### TR

    public static final java.lang.String TR

  The HTML "tr" tag.

  See Also:
    Constant Field Values

### TYPE

    public static final java.lang.String TYPE

  The HTML "type" attribute.

  See Also:
    Constant Field Values

### UL

    public static final java.lang.String UL

  The HTML "ul" tag.

  See Also:
    Constant Field Values

### VALIGN

    public static final java.lang.String VALIGN

  The HTML "valign" attribute.

  See Also:
    Constant Field Values

### VALUE

    public static final java.lang.String VALUE

  The HTML "value" attribute.

  See Also:
    Constant Field Values

Constructor Detail

### HTMLWriter

    public HTMLWriter(java.io.Writer out)
               throws java.io.IOException

  Create an HTMLWriter object, using a default doctype for HTML 3.2.

  Parameters:
    `out` - a Writer to which to write the generated HTML
  Throws:
    `java.io.IOException` - if there is a problem writing to the underlying stream

### HTMLWriter

    public HTMLWriter(java.io.Writer out,
                      java.lang.String docType)
               throws java.io.IOException

  Create an HTMLWriter object, using a specifed doctype header.

  Parameters:
    `out` - a Writer to which to write the generated HTML
    `docType` - a string containing a doctype header for the HTML to be generetaed
  Throws:
    `java.io.IOException` - if there is a problem writing to the underlying stream

### HTMLWriter

    public HTMLWriter(java.io.Writer out,
                      I18NResourceBundle i18n)
               throws java.io.IOException

  Create an HTMLWriter object, using a specified bundle for l0calizing messages.

  Parameters:
    `out` - a Writer to which to write the generated HTML
    `i18n` - a resource bundle to use to localize messages
  Throws:
    `java.io.IOException` - if there is a problem writing to the underlying stream

### HTMLWriter

    public HTMLWriter(java.io.Writer out,
                      java.lang.String docType,
                      I18NResourceBundle i18n)
               throws java.io.IOException

  Create an HTMLWriter object, using a specifed doctype header and using a specified bundle for l0calizing messages.

  Parameters:
    `out` - a Writer to which to write the generated HTML
    `docType` - a string containing a doctype header for the HTML to be generetaed
    `i18n` - a resource bundle to use to localize messages
  Throws:
    `java.io.IOException` - if there is a problem writing to the underlying stream

Method Detail

### setI18NResourceBundle

    public void setI18NResourceBundle(I18NResourceBundle i18n)

  Set the reource bundle to be used for localizing messages.

  Parameters:
    `i18n` - the resource bundle to be used for localizing messages

### flush

    public void flush()
               throws java.io.IOException

  Flush the stream, and the underlying output stream.

  Throws:
    `java.io.IOException` - if there is a problem writing to the underlying stream

### close

    public void close()
               throws java.io.IOException

  Close the stream, and the underlying output stream.

  Throws:
    `java.io.IOException` - if there is a problem closing the underlying stream

### newLine

    public void newLine()
                 throws java.io.IOException

  Write a newline to the underlying output stream.

  Throws:
    `java.io.IOException` - if there is a problem writing to the underlying stream

### startTag

    public void startTag(java.lang.String tag)
                  throws java.io.IOException

  Start an HTML 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:
    `java.io.IOException` - if there is a problem writing to the underlying stream
  See Also:
    `writeAttr(java.lang.String, java.lang.String)`, `write(java.lang.String)`, `endTag(java.lang.String)`

### endTag

    public void endTag(java.lang.String tag)
                throws java.io.IOException

  Finish an HTML 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:
    `java.io.IOException` - if there is a problem writing to the underlying stream

### endEmptyTag

    public void endEmptyTag(java.lang.String tag)
                     throws java.io.IOException

  Finish an empty element tag, such as a META, BASE or LINK tag. This is expected to correspond with a startTag.

  Parameters:
    `tag` - the tag which is being closed. this is only useful for validation, it is not written out
  Throws:
    `java.lang.IllegalStateException` - if this call does not follow startTag (stream is not currently inside a tag)
    `java.io.IOException` - if there is a problem writing to the underlying stream

### writeAttr

    public void writeAttr(java.lang.String name,
                          java.lang.String value)
                   throws java.io.IOException

  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 written
    `value` - the value of the attribute to be written
  Throws:
    `java.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 writteAttr
    `java.io.IOException` - if there is a problem writing to the underlying stream

### writeAttr

    public void writeAttr(java.lang.String name,
                          int value)
                   throws java.io.IOException

  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 written
    `value` - the value of the attribute to be written
  Throws:
    `java.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 writteAttr
    `java.io.IOException` - if there is a problem writing to the underlying stream

### writeLine

    public void writeLine(java.lang.String text)
                   throws java.io.IOException

  Write a line of text, followed by a newline. The text will be escaped as necessary.

  Parameters:
    `text` - the text to be written.
  Throws:
    `java.io.IOException` - if there is a problem closing the underlying stream

### write

    public void write(java.lang.String text)
               throws java.io.IOException

  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. If the text value is null, the current tag will still be closed, but no other text will be written.

  Parameters:
    `text` - the text to be written, may be null or zero length.
  Throws:
    `java.io.IOException` - if there is a problem writing to the underlying stream

### writeEntity

    public void writeEntity(java.lang.String entity)
                     throws java.io.IOException

  Write a basic HTML entity, such as or { .

  Parameters:
    `entity` - the entity to write
  Throws:
    `java.io.IOException` - if there is a problem writing to the underlying stream

### writeImage

    public void writeImage(java.lang.String imagePath)
                    throws java.io.IOException

  Write an image tag, using a specified path for the image source attribute.

  Parameters:
    `imagePath` - the path for the image source
  Throws:
    `java.io.IOException` - if there is a problem closing the underlying stream

### writeImage

    public void writeImage(java.net.URL imageURL)
                    throws java.io.IOException

  Write an image tag, using a specified path for the image source attribute.

  Parameters:
    `imageURL` - the url for the image source
  Throws:
    `java.io.IOException` - if there is a problem closing the underlying stream

### writeLink

    public void writeLink(java.lang.String anchor,
                          java.lang.String body)
                   throws java.io.IOException

  Write a hypertext link.

  Parameters:
    `anchor` - the target for the link
    `body` - the body text for the link
  Throws:
    `java.io.IOException` - if there is a problem closing the underlying stream

### writeLink

    public void writeLink(java.io.File file,
                          java.lang.String body)
                   throws java.io.IOException

  Write a hypertext link.

  Parameters:
    `file` - the target for the link
    `body` - the body text for the link
  Throws:
    `java.io.IOException` - if there is a problem closing the underlying stream

### writeLink

    public void writeLink(java.io.File file)
                   throws java.io.IOException

  Write a hypertext link.

  Parameters:
    `file` - the target and body for the link
  Throws:
    `java.io.IOException` - if there is a problem closing the underlying stream

### writeLink

    public void writeLink(java.net.URL url,
                          java.lang.String body)
                   throws java.io.IOException

  Write a hypertext link.

  Parameters:
    `url` - the target for the link
    `body` - the body text for the link
  Throws:
    `java.io.IOException` - if there is a problem closing the underlying stream

### writeLinkDestination

    public void writeLinkDestination(java.lang.String anchor,
                                     java.lang.String body)
                              throws java.io.IOException

  Write the destination marker for a hypertext link.

  Parameters:
    `anchor` - the destination marker for hypertext links
    `body` - the body text for the marker
  Throws:
    `java.io.IOException` - if there is a problem closing the underlying stream

### writeParam

    public void writeParam(java.lang.String name,
                           java.lang.String value)
                    throws java.io.IOException

  Write a parameter tag.

  Parameters:
    `name` - the name of the parameter
    `value` - the value of the parameter
  Throws:
    `java.io.IOException` - if there is a problem closing the underlying stream

### writeStyleAttr

    public void writeStyleAttr(java.lang.String value)
                        throws java.io.IOException

  Write a style attribute.

  Parameters:
    `value` - the value for the style atrtribute
  Throws:
    `java.io.IOException` - if there is a problem closing the underlying stream

### write

    public void write(I18NResourceBundle i18n,
                      java.lang.String key)
               throws java.io.IOException

  Write a localized message, using a specified resource bundle.

  Parameters:
    `i18n` - the resource bundle used to localize the message
    `key` - the key for the message to be localized
  Throws:
    `java.io.IOException` - if there is a problem closing the underlying stream

### write

    public void write(I18NResourceBundle i18n,
                      java.lang.String key,
                      java.lang.Object arg)
               throws java.io.IOException

  Write a localized message, using a specified resource bundle.

  Parameters:
    `i18n` - the resource bundle used to localize the message
    `key` - the key for the message to be localized
    `arg` - an argument to be formatted into the localized message
  Throws:
    `java.io.IOException` - if there is a problem closing the underlying stream

### write

    public void write(I18NResourceBundle i18n,
                      java.lang.String key,
                      java.lang.Object[] args)
               throws java.io.IOException

  Write a localized message, using a specified resource bundle.

  Parameters:
    `i18n` - the resource bundle used to localize the message
    `key` - the key for the message to be localized
    `args` - arguments to be formatted into the localized message
  Throws:
    `java.io.IOException` - if there is a problem closing the underlying stream

### writeI18N

    public void writeI18N(java.lang.String key)
                   throws java.io.IOException

  Write a localized message, using the default resource bundle.

  Parameters:
    `key` - the key for the message to be localized
  Throws:
    `java.io.IOException` - if there is a problem closing the underlying stream

### writeI18N

    public void writeI18N(java.lang.String key,
                          java.lang.Object arg)
                   throws java.io.IOException

  Write a localized message, using the default resource bundle.

  Parameters:
    `key` - the key for the message to be localized
    `arg` - an argument to be formatted into the localized message
  Throws:
    `java.io.IOException` - if there is a problem closing the underlying stream

### writeI18N

    public void writeI18N(java.lang.String key,
                          java.lang.Object[] args)
                   throws java.io.IOException

  Write a localized message, using the default resource bundle.

  Parameters:
    `key` - the key for the message to be localized
    `args` - arguments to be formatted into the localized message
  Throws:
    `java.io.IOException` - if there is a problem closing the underlying stream

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.