Spec-Zone .ru
спецификации, руководства, описания, API
JavaTM 2 Platform
Standard Edition

javax.swing.text.html
Class HTMLWriter

java.lang.Object
  |
  +--javax.swing.text.AbstractWriter
        |
        +--javax.swing.text.html.HTMLWriter

public class HTMLWriter
extends AbstractWriter

This is a writer for HTMLDocuments.


Fields inherited from class javax.swing.text.AbstractWriter
NEWLINE
 
Constructor Summary
HTMLWriter(Writer w, HTMLDocument doc)
          Creates a new HTMLWriter.
HTMLWriter(Writer w, HTMLDocument doc, int pos, int len)
          Creates a new HTMLWriter.
 
Method Summary
protected  void closeOutUnwantedEmbeddedTags(AttributeSet attr)
          This method searches the attribute set and for each tag that is stored in the tag vector.
protected  void comment(Element elem)
          Writes out comments.
protected  void decrIndent()
          Decrements the indent level.
protected  void emptyTag(Element elem)
          Writes out all empty elements i.e tags that have no corresponding end tag.
protected  void endTag(Element elem)
          Writes out an end tag for the element.
protected  void incrIndent()
          Increments the indent level.
protected  void indent()
          Does indentation.
protected  boolean isBlockTag(AttributeSet attr)
          Determines if the HTML.Tag associated with the element is a block tag.
protected  boolean matchNameAttribute(AttributeSet attr, HTML.Tag tag)
          This method return true if the StyleConstants.NameAttribute is equal to the tag that is passed in as a parameter.
protected  void selectContent(AttributeSet attr)
          Writes out the content of the SELECT form element.
protected  void setIndentSpace(int space)
          Enables subclasses to specify how many spaces an indent maps to.
protected  void setLineLength(int l)
          Enables subclasses to set the number of characters they want written per line.
protected  void startTag(Element elem)
          Writes out a start tag for the element.
protected  boolean synthesizedElement(Element elem)
          This method returns true, if the element is a synthesized element.
protected  void text(Element elem)
          Writes out text.
protected  void textAreaContent(AttributeSet attr)
          Writes out text that is contained in a TEXTAREA form element.
 void write()
          This is method that iterates over the the Element tree and controls the writing out of all the tags and its attributes.
protected  void write(char ch)
          Conveneice method for write(char, false).
protected  void write(String content)
          Convenience method for write(String, false).
protected  void writeAttributes(AttributeSet attr)
          Writes out the attribute set.
protected  void writeEmbeddedTags(AttributeSet attr)
          This method searches for embedded tags in the AttributeSet and writes them out.
protected  void writeOption(Option option)
          Writes out the content of the Option form element.
 
Methods inherited from class javax.swing.text.AbstractWriter
getDocument, getElementIterator, getText, inRange
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTMLWriter

public HTMLWriter(Writer w,
                  HTMLDocument doc)
Creates a new HTMLWriter.
Parameters:
a - Writer
an - HTMLDocument

HTMLWriter

public HTMLWriter(Writer w,
                  HTMLDocument doc,
                  int pos,
                  int len)
Creates a new HTMLWriter.
Parameters:
a - Writer
an - HTMLDocument
pos - The location in the document to fetch the content.
len - The amount to write out.
Method Detail

write

public void write()
           throws IOException,
                  BadLocationException
This is method that iterates over the the Element tree and controls the writing out of all the tags and its attributes.
Overrides:
write in class AbstractWriter
Throws:
IOException - on any I/O error
BadLocationException - if pos represents an invalid location within the document.

writeAttributes

protected void writeAttributes(AttributeSet attr)
                        throws 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 AbstractWriter
Parameters:
an - AttributeSet.
Throws:
IOException - on any I/O error

emptyTag

protected void emptyTag(Element elem)
                 throws BadLocationException,
                        IOException
Writes out all empty elements i.e tags that have no corresponding end tag.
Parameters:
an - Element.
Throws:
IOException - on any I/O error
BadLocationException - if pos represents an invalid location within the document.

isBlockTag

protected boolean isBlockTag(AttributeSet attr)
Determines if the HTML.Tag associated with the element is a block tag.
Parameters:
AttributeSet. -  
Returns:
true if tag is block tag, false otherwise.

startTag

protected void startTag(Element elem)
                 throws IOException,
                        BadLocationException
Writes out a start tag for the element. Ignores all synthesized elements.
Parameters:
an - Element.
Throws:
IOException - on any I/O error

textAreaContent

protected void textAreaContent(AttributeSet attr)
                        throws BadLocationException,
                               IOException
Writes out text that is contained in a TEXTAREA form element.
Parameters:
AttributeSet -  
Throws:
IOException - on any I/O error
BadLocationException - if pos represents an invalid location within the document.

text

protected void text(Element elem)
             throws BadLocationException,
                    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 AbstractWriter
Parameters:
an - Element.
Throws:
IOException - on any I/O error
BadLocationException - if pos represents an invalid location within the document.

selectContent

protected void selectContent(AttributeSet attr)
                      throws IOException
Writes out the content of the SELECT form element.
Parameters:
AttributeSet - associcated with the form element.
Throws:
IOException - on any I/O error

writeOption

protected void writeOption(Option option)
                    throws IOException
Writes out the content of the Option form element.
Parameters:
Option. -  
Throws:
IOException - on any I/O error

endTag

protected void endTag(Element elem)
               throws IOException
Writes out an end tag for the element.
Parameters:
an - Element.
Throws:
IOException - on any I/O error

comment

protected void comment(Element elem)
                throws BadLocationException,
                       IOException
Writes out comments.
Parameters:
an - element.
Throws:
IOException - on any I/O error
BadLocationException - if pos represents an invalid location within the document.

synthesizedElement

protected boolean synthesizedElement(Element elem)
This method returns true, if the element is a synthesized element. Currently we are only testing for the p-implied tag.

matchNameAttribute

protected boolean matchNameAttribute(AttributeSet attr,
                                     HTML.Tag tag)
This method return true if the StyleConstants.NameAttribute is equal to the tag that is passed in as a parameter.

writeEmbeddedTags

protected void writeEmbeddedTags(AttributeSet attr)
                          throws IOException
This method 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

closeOutUnwantedEmbeddedTags

protected void closeOutUnwantedEmbeddedTags(AttributeSet attr)
                                     throws IOException
This method 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

setIndentSpace

protected void setIndentSpace(int space)
Enables subclasses to specify how many spaces an indent maps to. When indentation takes place, the indent level is multiplied by this mapping. The default is 2.
Overrides:
setIndentSpace in class AbstractWriter
Parameters:
an - int representing the space to indent mapping.

incrIndent

protected void incrIndent()
Increments the indent level.
Overrides:
incrIndent in class AbstractWriter

decrIndent

protected void decrIndent()
Decrements the indent level.
Overrides:
decrIndent in class AbstractWriter

setLineLength

protected void setLineLength(int l)
Enables subclasses to set the number of characters they want written per line. The default is 100.
Overrides:
setLineLength in class AbstractWriter
Parameters:
the - maximum line length.

write

protected void write(char ch)
              throws IOException
Conveneice method for write(char, false).
Overrides:
write in class AbstractWriter
Tags copied from class: AbstractWriter
Parameters:
a - char.
Throws:
IOException - on any I/O error

write

protected void write(String content)
              throws IOException
Convenience method for write(String, false).
Overrides:
write in class AbstractWriter
Tags copied from class: AbstractWriter
Parameters:
a - String.
Throws:
IOException - on any I/O error

indent

protected void indent()
               throws IOException
Does indentation. The number of spaces written out is indent level times the space to map mapping.
Overrides:
indent in class AbstractWriter
Throws:
IOException - on any I/O error

JavaTM 2 Platform
Standard Edition

Submit a bug or feature
Java, Java 2D, and JDBC are a trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.