Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

javax.swing.text.html
Class HTMLDocument.HTMLReader  view HTMLDocument.HTMLReader download HTMLDocument.HTMLReader.java

java.lang.Object
  extended byjavax.swing.text.html.HTMLEditorKit.ParserCallback
      extended byjavax.swing.text.html.HTMLDocument.HTMLReader
Enclosing class:
HTMLDocument

public class HTMLDocument.HTMLReader
extends HTMLEditorKit.ParserCallback

A reader to load an HTMLDocument with HTML structure.


Nested Class Summary
(package private)  class HTMLDocument.HTMLReader.AreaAction
           
(package private)  class HTMLDocument.HTMLReader.BaseAction
           
 class HTMLDocument.HTMLReader.BlockAction
           
 class HTMLDocument.HTMLReader.CharacterAction
           
 class HTMLDocument.HTMLReader.FormAction
           
(package private)  class HTMLDocument.HTMLReader.HeadAction
           
 class HTMLDocument.HTMLReader.HiddenAction
           
 class HTMLDocument.HTMLReader.IsindexAction
           
(package private)  class HTMLDocument.HTMLReader.LinkAction
           
(package private)  class HTMLDocument.HTMLReader.MapAction
           
(package private)  class HTMLDocument.HTMLReader.MetaAction
           
 class HTMLDocument.HTMLReader.ParagraphAction
           
 class HTMLDocument.HTMLReader.PreAction
           
 class HTMLDocument.HTMLReader.SpecialAction
           
(package private)  class HTMLDocument.HTMLReader.StyleAction
           
 class HTMLDocument.HTMLReader.TagAction
           
(package private)  class HTMLDocument.HTMLReader.TitleAction
           
 
Field Summary
protected  javax.swing.text.MutableAttributeSet charAttr
          Holds the current character attribute set
(package private)  java.util.Stack charAttrStack
          A stack for character attribute sets
(package private)  boolean debug
          A temporary variable that helps with the printing out of debug information
(package private)  boolean endHTMLEncountered
          Tells us whether we've received the '' tag yet
(package private)  HTML.Tag insertTag
           
(package private)  boolean insertTagEncountered
           
(package private)  int offset
          Variables related to the constructor with explicit insertTag
protected  java.util.Vector parseBuffer
           
private  java.util.Stack parseStack
          The parse stack.
(package private)  int popDepth
          Variables related to the constructor with explicit insertTag
(package private)  int pushDepth
          Variables related to the constructor with explicit insertTag
(package private)  java.util.HashMap tagToAction
          A mapping between HTML.Tag objects and the actions that handle them
 
Fields inherited from class javax.swing.text.html.HTMLEditorKit.ParserCallback
IMPLIED
 
Constructor Summary
HTMLDocument.HTMLReader(int offset)
           
HTMLDocument.HTMLReader(int offset, int popDepth, int pushDepth, HTML.Tag insertTag)
           
 
Method Summary
protected  void addContent(char[] data, int offs, int length)
          Adds text to the appropriate context using the current character attribute set.
protected  void addContent(char[] data, int offs, int length, boolean generateImpliedPIfNecessary)
          Adds text to the appropriate context using the current character attribute set, and possibly generating an IMPLIED Tag if necessary.
protected  void addSpecialElement(HTML.Tag t, javax.swing.text.MutableAttributeSet a)
          Adds content that is specified in the attribute set.
protected  void blockClose(HTML.Tag t)
          Instructs the parse buffer to close the block element associated with the given HTML.Tag
protected  void blockOpen(HTML.Tag t, javax.swing.text.MutableAttributeSet attr)
          Instructs the parse buffer to create a block element with the given attributes.
 void flush()
          This is the last method called on the HTMLReader, allowing any pending changes to be flushed to the HTMLDocument.
 void handleComment(char[] data, int pos)
          This method called by parser to handle a comment block.
 void handleEndOfLineString(java.lang.String eol)
          This is invoked after the stream has been parsed but before it has been flushed.
 void handleEndTag(HTML.Tag t, int pos)
          This method is called by the parser and should route the call to the proper handler for the tag.
 void handleSimpleTag(HTML.Tag t, javax.swing.text.MutableAttributeSet a, int pos)
          This is a callback from the parser that should be routed to the appropriate handler for the tag.
 void handleStartTag(HTML.Tag t, javax.swing.text.MutableAttributeSet a, int pos)
          This method is called by the parser and should route the call to the proper handler for the tag.
 void handleText(char[] data, int pos)
          This method is called by the parser to indicate a block of text was encountered.
(package private)  void initTags()
           
protected  void popCharacterStyle()
          Pops a character style off of the stack and uses it as the current character style.
protected  void preContent(char[] data)
          Adds the given text that was encountered in a
(package private)  void print(java.lang.String line)
           
(package private)  void printBuffer()
           
protected  void pushCharacterStyle()
          Pushes the current character style onto the stack.
protected  void registerTag(HTML.Tag t, HTMLDocument.HTMLReader.TagAction a)
          Registers a given tag with a given Action.
protected  void textAreaContent(char[] data)
          Adds the given text to the textarea document.
 
Methods inherited from class javax.swing.text.html.HTMLEditorKit.ParserCallback
handleError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

charAttr

protected javax.swing.text.MutableAttributeSet charAttr
Holds the current character attribute set


parseBuffer

protected java.util.Vector parseBuffer

charAttrStack

java.util.Stack charAttrStack
A stack for character attribute sets


parseStack

private java.util.Stack parseStack
The parse stack. This stack holds HTML.Tag objects that reflect the current position in the parsing process.


tagToAction

java.util.HashMap tagToAction
A mapping between HTML.Tag objects and the actions that handle them


endHTMLEncountered

boolean endHTMLEncountered
Tells us whether we've received the '' tag yet


popDepth

int popDepth
Variables related to the constructor with explicit insertTag


pushDepth

int pushDepth
Variables related to the constructor with explicit insertTag


offset

int offset
Variables related to the constructor with explicit insertTag


insertTag

HTML.Tag insertTag

insertTagEncountered

boolean insertTagEncountered

debug

boolean debug
A temporary variable that helps with the printing out of debug information

Constructor Detail

HTMLDocument.HTMLReader

public HTMLDocument.HTMLReader(int offset)

HTMLDocument.HTMLReader

public HTMLDocument.HTMLReader(int offset,
                               int popDepth,
                               int pushDepth,
                               HTML.Tag insertTag)
Method Detail

print

void print(java.lang.String line)

initTags

void initTags()

pushCharacterStyle

protected void pushCharacterStyle()
Pushes the current character style onto the stack.


popCharacterStyle

protected void popCharacterStyle()
Pops a character style off of the stack and uses it as the current character style.


registerTag

protected void registerTag(HTML.Tag t,
                           HTMLDocument.HTMLReader.TagAction a)
Registers a given tag with a given Action. All of the well-known tags are registered by default, but this method can change their behaviour or add support for custom or currently unsupported tags.


flush

public void flush()
           throws javax.swing.text.BadLocationException
This is the last method called on the HTMLReader, allowing any pending changes to be flushed to the HTMLDocument.

Overrides:
flush in class HTMLEditorKit.ParserCallback

handleText

public void handleText(char[] data,
                       int pos)
This method is called by the parser to indicate a block of text was encountered. Should insert the text appropriately.

Overrides:
handleText in class HTMLEditorKit.ParserCallback

handleStartTag

public void handleStartTag(HTML.Tag t,
                           javax.swing.text.MutableAttributeSet a,
                           int pos)
This method is called by the parser and should route the call to the proper handler for the tag.

Overrides:
handleStartTag in class HTMLEditorKit.ParserCallback

handleComment

public void handleComment(char[] data,
                          int pos)
This method called by parser to handle a comment block.

Overrides:
handleComment in class HTMLEditorKit.ParserCallback

handleEndTag

public void handleEndTag(HTML.Tag t,
                         int pos)
This method is called by the parser and should route the call to the proper handler for the tag.

Overrides:
handleEndTag in class HTMLEditorKit.ParserCallback

handleSimpleTag

public void handleSimpleTag(HTML.Tag t,
                            javax.swing.text.MutableAttributeSet a,
                            int pos)
This is a callback from the parser that should be routed to the appropriate handler for the tag.

Overrides:
handleSimpleTag in class HTMLEditorKit.ParserCallback

handleEndOfLineString

public void handleEndOfLineString(java.lang.String eol)
                           throws gnu.classpath.NotImplementedException
This is invoked after the stream has been parsed but before it has been flushed.

Overrides:
handleEndOfLineString in class HTMLEditorKit.ParserCallback
Since:
1.3

textAreaContent

protected void textAreaContent(char[] data)
                        throws gnu.classpath.NotImplementedException
Adds the given text to the textarea document. Called only when we are within a textarea.


preContent

protected void preContent(char[] data)
                   throws gnu.classpath.NotImplementedException
Adds the given text that was encountered in a
 element.


blockOpen

protected void blockOpen(HTML.Tag t,
                         javax.swing.text.MutableAttributeSet attr)
Instructs the parse buffer to create a block element with the given attributes.


blockClose

protected void blockClose(HTML.Tag t)
Instructs the parse buffer to close the block element associated with the given HTML.Tag


addContent

protected void addContent(char[] data,
                          int offs,
                          int length)
Adds text to the appropriate context using the current character attribute set.


addContent

protected void addContent(char[] data,
                          int offs,
                          int length,
                          boolean generateImpliedPIfNecessary)
Adds text to the appropriate context using the current character attribute set, and possibly generating an IMPLIED Tag if necessary.


addSpecialElement

protected void addSpecialElement(HTML.Tag t,
                                 javax.swing.text.MutableAttributeSet a)
                          throws gnu.classpath.NotImplementedException
Adds content that is specified in the attribute set.


printBuffer

void printBuffer()