com.lightdev.app.shtm
Class FixedHTMLWriter

java.lang.Object
  extended by javax.swing.text.AbstractWriter
      extended by javax.swing.text.html.HTMLWriter
          extended by com.lightdev.app.shtm.FixedHTMLWriter

public class FixedHTMLWriter
extends javax.swing.text.html.HTMLWriter

FixedHTMLWriter

This is the standard HTMLWriter from package javax.swing.text.html. It only has been changed in method 'createFontAttribute' so that font sizes are written correctly inside content

.


Field Summary
 
Fields inherited from class javax.swing.text.AbstractWriter
NEWLINE
 
Constructor Summary
FixedHTMLWriter(java.io.Writer w, javax.swing.text.html.HTMLDocument doc)
          Creates a new HTMLWriter.
FixedHTMLWriter(java.io.Writer w, javax.swing.text.html.HTMLDocument doc, int pos, int len)
          Creates a new HTMLWriter.
 
Method Summary
protected  void closeOutUnwantedEmbeddedTags(javax.swing.text.AttributeSet attr)
          Searches the attribute set and for each tag that is stored in the tag vector.
protected  void comment(javax.swing.text.Element elem)
          Writes out comments.
protected  void emptyTag(javax.swing.text.Element elem)
          Writes out all empty elements (all tags that have no corresponding end tag).
protected  void endTag(javax.swing.text.Element elem)
          Writes out an end tag for the element.
protected  boolean isBlockTag(javax.swing.text.AttributeSet attr)
          Determines if the HTML.Tag associated with the element is a block tag.
protected  boolean matchNameAttribute(javax.swing.text.AttributeSet attr, javax.swing.text.html.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;.
protected  void selectContent(javax.swing.text.AttributeSet attr)
          Writes out the content of the SELECT form element.
protected  void startTag(javax.swing.text.Element elem)
          Writes out a start tag for the element.
protected  boolean synthesizedElement(javax.swing.text.Element elem)
          Returns true if the element is a synthesized element.
protected  void text(javax.swing.text.Element elem)
          Writes out text.
protected  void textAreaContent(javax.swing.text.AttributeSet attr)
          Writes out text that is contained in a TEXTAREA form element.
 void write()
          Iterates over the Element tree and controls the writing out of all the tags and its attributes.
protected  void writeAttributes(javax.swing.text.AttributeSet attr)
          Writes out the attribute set.
protected  void writeEmbeddedTags(javax.swing.text.AttributeSet attr)
          Searches for embedded tags in the AttributeSet and writes them out.
protected  void writeLineSeparator()
          Writes the line separator.
protected  void writeOption(javax.swing.text.html.Option option)
          Writes out the content of the Option form element.
 
Methods inherited from class javax.swing.text.AbstractWriter
decrIndent, getCanWrapLines, getCurrentLineLength, getDocument, getElementIterator, getEndOffset, getIndentLevel, getIndentSpace, getLineLength, getLineSeparator, getStartOffset, getText, getWriter, incrIndent, indent, inRange, isLineEmpty, setCanWrapLines, setCurrentLineLength, setIndentSpace, setLineLength, setLineSeparator, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FixedHTMLWriter

public FixedHTMLWriter(java.io.Writer w,
                       javax.swing.text.html.HTMLDocument doc)
Creates a new HTMLWriter.

Parameters:
w - a Writer
doc - an HTMLDocument

FixedHTMLWriter

public FixedHTMLWriter(java.io.Writer w,
                       javax.swing.text.html.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
Method Detail

write

public void write()
           throws java.io.IOException,
                  javax.swing.text.BadLocationException
Iterates over the Element tree and controls the writing out of all the tags and its attributes.

Overrides:
write in class javax.swing.text.html.HTMLWriter
Throws:
java.io.IOException - on any I/O error
javax.swing.text.BadLocationException - if pos represents an invalid location within the document.

writeAttributes

protected void writeAttributes(javax.swing.text.AttributeSet attr)
                        throws java.io.IOException
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.

Overrides:
writeAttributes in class javax.swing.text.html.HTMLWriter
Parameters:
attr - an AttributeSet
Throws:
java.io.IOException - on any I/O error

emptyTag

protected void emptyTag(javax.swing.text.Element elem)
                 throws javax.swing.text.BadLocationException,
                        java.io.IOException
Writes out all empty elements (all tags that have no corresponding end tag).

Overrides:
emptyTag in class javax.swing.text.html.HTMLWriter
Parameters:
elem - an Element
Throws:
java.io.IOException - on any I/O error
javax.swing.text.BadLocationException - if pos represents an invalid location within the document.

isBlockTag

protected boolean isBlockTag(javax.swing.text.AttributeSet attr)
Determines if the HTML.Tag associated with the element is a block tag.

Overrides:
isBlockTag in class javax.swing.text.html.HTMLWriter
Parameters:
attr - an AttributeSet
Returns:
true if tag is block tag, false otherwise.

startTag

protected void startTag(javax.swing.text.Element elem)
                 throws java.io.IOException,
                        javax.swing.text.BadLocationException
Writes out a start tag for the element. Ignores all synthesized elements.

Overrides:
startTag in class javax.swing.text.html.HTMLWriter
Parameters:
elem - an Element
Throws:
java.io.IOException - on any I/O error
javax.swing.text.BadLocationException

textAreaContent

protected void textAreaContent(javax.swing.text.AttributeSet attr)
                        throws javax.swing.text.BadLocationException,
                               java.io.IOException
Writes out text that is contained in a TEXTAREA form element.

Overrides:
textAreaContent in class javax.swing.text.html.HTMLWriter
Parameters:
attr - an AttributeSet
Throws:
java.io.IOException - on any I/O error
javax.swing.text.BadLocationException - if pos represents an invalid location within the document.

text

protected void text(javax.swing.text.Element elem)
             throws javax.swing.text.BadLocationException,
                    java.io.IOException
Writes out text. If a range is specified when the constructor is invoked, then only the appropriate range of text is written out.

Overrides:
text in class javax.swing.text.html.HTMLWriter
Parameters:
elem - an Element
Throws:
java.io.IOException - on any I/O error
javax.swing.text.BadLocationException - if pos represents an invalid location within the document.

selectContent

protected void selectContent(javax.swing.text.AttributeSet attr)
                      throws java.io.IOException
Writes out the content of the SELECT form element.

Overrides:
selectContent in class javax.swing.text.html.HTMLWriter
Parameters:
attr - the AttributeSet associated with the form element
Throws:
java.io.IOException - on any I/O error

writeOption

protected void writeOption(javax.swing.text.html.Option option)
                    throws java.io.IOException
Writes out the content of the Option form element.

Overrides:
writeOption in class javax.swing.text.html.HTMLWriter
Parameters:
option - an Option
Throws:
java.io.IOException - on any I/O error

endTag

protected void endTag(javax.swing.text.Element elem)
               throws java.io.IOException
Writes out an end tag for the element.

Overrides:
endTag in class javax.swing.text.html.HTMLWriter
Parameters:
elem - an Element
Throws:
java.io.IOException - on any I/O error

comment

protected void comment(javax.swing.text.Element elem)
                throws javax.swing.text.BadLocationException,
                       java.io.IOException
Writes out comments.

Overrides:
comment in class javax.swing.text.html.HTMLWriter
Parameters:
elem - an Element
Throws:
java.io.IOException - on any I/O error
javax.swing.text.BadLocationException - if pos represents an invalid location within the document.

synthesizedElement

protected boolean synthesizedElement(javax.swing.text.Element elem)
Returns true if the element is a synthesized element. Currently we are only testing for the p-implied tag.

Overrides:
synthesizedElement in class javax.swing.text.html.HTMLWriter

matchNameAttribute

protected boolean matchNameAttribute(javax.swing.text.AttributeSet attr,
                                     javax.swing.text.html.HTML.Tag tag)
Returns true if the StyleConstants.NameAttribute is equal to the tag that is passed in as a parameter.

Overrides:
matchNameAttribute in class javax.swing.text.html.HTMLWriter

writeEmbeddedTags

protected void writeEmbeddedTags(javax.swing.text.AttributeSet attr)
                          throws java.io.IOException
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.

Overrides:
writeEmbeddedTags in class javax.swing.text.html.HTMLWriter
Throws:
java.io.IOException - on any I/O error

closeOutUnwantedEmbeddedTags

protected void closeOutUnwantedEmbeddedTags(javax.swing.text.AttributeSet attr)
                                     throws java.io.IOException
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.

Overrides:
closeOutUnwantedEmbeddedTags in class javax.swing.text.html.HTMLWriter
Throws:
java.io.IOException - on any I/O error

writeLineSeparator

protected void writeLineSeparator()
                           throws java.io.IOException
Writes the line separator. This is overriden to make sure we don't replace the newline content in case it is outside normal ascii.

Overrides:
writeLineSeparator in class javax.swing.text.html.HTMLWriter
Throws:
java.io.IOException

output

protected void output(char[] chars,
                      int start,
                      int length)
               throws java.io.IOException
This method is overriden to map any character entities, such as < to &lt;. super.output will be invoked to write the content.

Overrides:
output in class javax.swing.text.html.HTMLWriter
Throws:
java.io.IOException