edu.nrao.sss.html
Class HtmlTableTagHandler

java.lang.Object
  extended by javax.swing.text.html.HTMLEditorKit.ParserCallback
      extended by edu.nrao.sss.html.HtmlTableTagHandler

public class HtmlTableTagHandler
extends HTMLEditorKit.ParserCallback

A handler of table-related HTML tags that may be called by subclasses of HTMLEditorKit.Parser. Example of use:

     ParserDelegator parser = new ParserDelegator();

     parser.parse(new InputStreamReader(htmlPage.openStream()),
                  new HtmlTableTagHandler(myTableList), true);
 

Version Info:

$Revision: 545 $
$Date: 2007-04-19 10:38:45 -0600 (Thu, 19 Apr 2007) $
$Author: dharland $

Since:
2007-03-16
Author:
David M. Harland

Field Summary
 
Fields inherited from class javax.swing.text.html.HTMLEditorKit.ParserCallback
IMPLIED
 
Constructor Summary
HtmlTableTagHandler(int tableOccurrenceToRead, HtmlTable destination)
          Creates a handler that will place the nth occurrence of an HTML table presented to it into destination, where n is tableOccurrenceToRead.
HtmlTableTagHandler(List<HtmlTable> destination)
          Creates a handler that will append all tables parsed to the given list.
 
Method Summary
 void flush()
           
 void handleEndTag(HTML.Tag tag, int pos)
          Handles end tags for table, table row, table data, and table header.
 void handleError(String errMsg, int pos)
           
 void handleSimpleTag(HTML.Tag tag, MutableAttributeSet attrs, int pos)
          If the simple tag is inside a table cell, it is added to that cell's unparsed contents, otherwise it is ignored.
 void handleStartTag(HTML.Tag tag, MutableAttributeSet attrs, int pos)
          Handles start tags for table, table row, table data, and table header.
 void handleText(char[] data, int pos)
          If the text is inside a table cell, it is added to that cell's unparsed contents, otherwise it is ignored.
 void reset()
           
 void reset(int tableOccurrenceToRead, HtmlTable destination)
           
 void reset(List<HtmlTable> destination)
           
 
Methods inherited from class javax.swing.text.html.HTMLEditorKit.ParserCallback
handleComment, handleEndOfLineString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HtmlTableTagHandler

public HtmlTableTagHandler(int tableOccurrenceToRead,
                           HtmlTable destination)
Creates a handler that will place the nth occurrence of an HTML table presented to it into destination, where n is tableOccurrenceToRead. Indexing begins with zero.

Note: a table inside of another table will not be counted as a new table for purposes of counting occurrences.

Parameters:
tableOccurrenceToRead - the occurrence of an HTML table to be saved. Indexing begins at zero.
destination - the table to populate. This value must not be null. If it is, the parsing process will throw a NullPointerException.

HtmlTableTagHandler

public HtmlTableTagHandler(List<HtmlTable> destination)
Creates a handler that will append all tables parsed to the given list.

Parameters:
destination - the list to which parsed tables will be appended. This list may or may not be empty, but must not be null. If it is, the parsing process will throw a NullPointerException.
Method Detail

reset

public void reset()

reset

public void reset(int tableOccurrenceToRead,
                  HtmlTable destination)

reset

public void reset(List<HtmlTable> destination)

handleStartTag

public void handleStartTag(HTML.Tag tag,
                           MutableAttributeSet attrs,
                           int pos)
Handles start tags for table, table row, table data, and table header. Any other start tag is ignored, unless it is inside a table cell, in which case it is added to the cell's unparsed content without being interpreted as an HTML element.

Overrides:
handleStartTag in class HTMLEditorKit.ParserCallback

handleEndTag

public void handleEndTag(HTML.Tag tag,
                         int pos)
Handles end tags for table, table row, table data, and table header. Any other start tag is ignored, unless it is inside a table cell, in which case it is added to the cell's unparsed content without being interpreted as an HTML element.

Overrides:
handleEndTag in class HTMLEditorKit.ParserCallback

handleSimpleTag

public void handleSimpleTag(HTML.Tag tag,
                            MutableAttributeSet attrs,
                            int pos)
If the simple tag is inside a table cell, it is added to that cell's unparsed contents, otherwise it is ignored.

Overrides:
handleSimpleTag in class HTMLEditorKit.ParserCallback

handleText

public void handleText(char[] data,
                       int pos)
If the text is inside a table cell, it is added to that cell's unparsed contents, otherwise it is ignored.

Overrides:
handleText in class HTMLEditorKit.ParserCallback

flush

public void flush()
Overrides:
flush in class HTMLEditorKit.ParserCallback

handleError

public void handleError(String errMsg,
                        int pos)
Overrides:
handleError in class HTMLEditorKit.ParserCallback


Copyright © 2009. All Rights Reserved.