public class

HTMLWriter

extends AbstractWriter
java.lang.Object
   ↳ javax.swing.text.AbstractWriter
     ↳ javax.swing.text.html.HTMLWriter

Class Overview

This is a writer for HTMLDocuments.

Summary

[Expand]
Inherited Constants
From class javax.swing.text.AbstractWriter
Public Constructors
HTMLWriter(Writer w, HTMLDocument doc)
Creates a new HTMLWriter.
HTMLWriter(Writer w, HTMLDocument doc, int pos, int len)
Creates a new HTMLWriter.
Public Methods
void write()
Iterates over the Element tree and controls the writing out of all the tags and its attributes.
Protected Methods
void closeOutUnwantedEmbeddedTags(AttributeSet attr)
Searches the attribute set and for each tag that is stored in the tag vector.
void comment(Element elem)
Writes out comments.
void emptyTag(Element elem)
Writes out all empty elements (all tags that have no corresponding end tag).
void endTag(Element elem)
Writes out an end tag for the element.
boolean isBlockTag(AttributeSet attr)
Determines if the HTML.Tag associated with the element is a block tag.
boolean matchNameAttribute(AttributeSet attr, HTML.Tag tag)
Returns true if the StyleConstants.NameAttribute is equal to the tag that is passed in as a parameter.
void output(char[] chars, int start, int length)
This method is overriden to map any character entities, such as < to &lt;.
void selectContent(AttributeSet attr)
Writes out the content of the SELECT form element.
void startTag(Element elem)
Writes out a start tag for the element.
boolean synthesizedElement(Element elem)
Returns true if the element is a synthesized element.
void text(Element elem)
Writes out text.
void textAreaContent(AttributeSet attr)
Writes out text that is contained in a TEXTAREA form element.
void writeAttributes(AttributeSet attr)
Writes out the attribute set.
void writeEmbeddedTags(AttributeSet attr)
Searches for embedded tags in the AttributeSet and writes them out.
void writeLineSeparator()
Writes the line separator.
void writeOption(Option option)
Writes out the content of the Option form element.
[Expand]
Inherited Methods
From class javax.swing.text.AbstractWriter
From class java.lang.Object

Public Constructors

public HTMLWriter (Writer w, HTMLDocument doc)

Creates a new HTMLWriter.

Parameters
w a Writer
doc an HTMLDocument

public HTMLWriter (Writer w, HTMLDocument doc, int pos, int len)

Creates a new HTMLWriter.

Parameters
w a Writer
doc an HTMLDocument
pos the document location from which to fetch the content
len the amount to write out

Public Methods

public void write ()

Iterates over the Element tree and controls the writing out of all the tags and its attributes.

Throws
IOException on any I/O error
BadLocationException if pos represents an invalid location within the document.

Protected Methods

protected void closeOutUnwantedEmbeddedTags (AttributeSet attr)

Searches the attribute set and for each tag that is stored in the tag vector. If the tag isnt found, then the tag is removed from the vector and a corresponding end tag is written out.

Throws
IOException on any I/O error

protected void comment (Element elem)

Writes out comments.

Parameters
elem an Element
Throws
IOException on any I/O error
BadLocationException if pos represents an invalid location within the document.

protected void emptyTag (Element elem)

Writes out all empty elements (all tags that have no corresponding end tag).

Parameters
elem an Element
Throws
IOException on any I/O error
BadLocationException if pos represents an invalid location within the document.

protected void endTag (Element elem)

Writes out an end tag for the element.

Parameters
elem an Element
Throws
IOException on any I/O error

protected boolean isBlockTag (AttributeSet attr)

Determines if the HTML.Tag associated with the element is a block tag.

Parameters
attr an AttributeSet
Returns
  • true if tag is block tag, false otherwise.

protected boolean matchNameAttribute (AttributeSet attr, HTML.Tag tag)

Returns true if the StyleConstants.NameAttribute is equal to the tag that is passed in as a parameter.

protected void output (char[] chars, int start, int length)

This method is overriden to map any character entities, such as < to &lt;. super.output will be invoked to write the content.

Throws
IOException

protected void selectContent (AttributeSet attr)

Writes out the content of the SELECT form element.

Parameters
attr the AttributeSet associated with the form element
Throws
IOException on any I/O error

protected void startTag (Element elem)

Writes out a start tag for the element. Ignores all synthesized elements.

Parameters
elem an Element
Throws
IOException on any I/O error
BadLocationException

protected boolean synthesizedElement (Element elem)

Returns true if the element is a synthesized element. Currently we are only testing for the p-implied tag.

protected void text (Element elem)

Writes out text. If a range is specified when the constructor is invoked, then only the appropriate range of text is written out.

Parameters
elem an Element
Throws
IOException on any I/O error
BadLocationException if pos represents an invalid location within the document.

protected void textAreaContent (AttributeSet attr)

Writes out text that is contained in a TEXTAREA form element.

Parameters
attr an AttributeSet
Throws
IOException on any I/O error
BadLocationException if pos represents an invalid location within the document.

protected void writeAttributes (AttributeSet attr)

Writes out the attribute set. Ignores all attributes with a key of type HTML.Tag, attributes with a key of type StyleConstants, and attributes with a key of type HTML.Attribute.ENDTAG.

Parameters
attr an AttributeSet
Throws
IOException on any I/O error

protected void writeEmbeddedTags (AttributeSet attr)

Searches for embedded tags in the AttributeSet and writes them out. It also stores these tags in a vector so that when appropriate the corresponding end tags can be written out.

Throws
IOException on any I/O error

protected void writeLineSeparator ()

Writes the line separator. This is overriden to make sure we don't replace the newline content in case it is outside normal ascii.

Throws
IOException

protected void writeOption (Option option)

Writes out the content of the Option form element.

Parameters
option an Option
Throws
IOException on any I/O error