hotsax.html.sax
Class SaxHandlerDelegate

java.lang.Object
  extended by hotsax.html.sax.SaxHandlerDelegate
All Implemented Interfaces:
ParserDelegate

public class SaxHandlerDelegate
extends Object
implements ParserDelegate

SaxHandlerDelegate - provides a clean interface between the Byacc/J generated HtmlParse and the SaxParser.


Constructor Summary
SaxHandlerDelegate(HtmlParser HtmlParser)
           
 
Method Summary
 void addAttribute(String name, String value)
          Adds an attribute to the list.
 void characters(HtmlParserVal lval)
          collect characters from parse stream.
 void comment(HtmlParserVal lval)
          comment handler Note, these are delegate to the XMLReader's LexicalHandler if any TODO: Check the property of the reader for its existance.
 void endCDATA()
          CDATA handler Note, these are delegate to the XMLReader's LexicalHandler if any This only marks the end boundary of the CDATA section.
 void endDocument()
          Fire endDocument event.
 void endDTD()
          End the DOCTYPE declaration
 void endElement(HtmlParserVal lval)
          Fire endElement event.
 HtmlParserVal getAttributes()
           
 void processingInstruction(HtmlParserVal target, HtmlParserVal lval)
          Parse a PI and pass it to the contentHandler event (does not pass xml declaration: ) Separates the target from the data by using whitespace.
 void setXMLReader(XMLReader reader)
          used by the SaxParser to set itself in ParserDelegate
 void startCDATA()
          CDATA handler Note, these are delegate to the XMLReader's LexicalHandler if any This only marks the start boundary condition.
 void startDocument()
          Parse a startDocument event and pass it to the resigtered content handler.
 void startDTD(HtmlParserVal lval)
          Start the beginning of the DOCTYPE (DTD) declaration Note, these are delegate to the XMLReader's LexicalHandler if any
 void startElement()
          Initialize the start of a start element.
 void startElement(HtmlParserVal lval)
          Fire startElement event.
 void startElement(HtmlParserVal lval, HtmlParserVal attrList)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SaxHandlerDelegate

public SaxHandlerDelegate(HtmlParser HtmlParser)
Method Detail

startDocument

public void startDocument()
Parse a startDocument event and pass it to the resigtered content handler. This method fires in response to a HtmlParser.EOF lexer token beging recognised. SOF is a virtual token fired as the first event after the file is opened.

Specified by:
startDocument in interface ParserDelegate

processingInstruction

public void processingInstruction(HtmlParserVal target,
                                  HtmlParserVal lval)
Parse a PI and pass it to the contentHandler event (does not pass xml declaration: ) Separates the target from the data by using whitespace.

Specified by:
processingInstruction in interface ParserDelegate

startElement

public void startElement()
Initialize the start of a start element. Prepares the attribute list to collect any attributes.

Specified by:
startElement in interface ParserDelegate

addAttribute

public void addAttribute(String name,
                         String value)
Adds an attribute to the list. The name of the attribute is normalized to lowercase

Specified by:
addAttribute in interface ParserDelegate

getAttributes

public HtmlParserVal getAttributes()
Specified by:
getAttributes in interface ParserDelegate

startElement

public void startElement(HtmlParserVal lval,
                         HtmlParserVal attrList)
Specified by:
startElement in interface ParserDelegate

startElement

public void startElement(HtmlParserVal lval)
Fire startElement event. Note handled the actual beginning of the element by now and have collected all attributes (if any)

Specified by:
startElement in interface ParserDelegate

characters

public void characters(HtmlParserVal lval)
collect characters from parse stream. Unwrap the HtmlParserVal.sval String to a character array. TODO: After creating a LexicalHandler, make sure this gets called in the comment state. TODO: This might be better done in the collection process rather than always using a String. I.e. getting a bunch of chars instead of incrementally appending one char at a time from yytext()

Specified by:
characters in interface ParserDelegate

endElement

public void endElement(HtmlParserVal lval)
Fire endElement event. The name of the element is passed to the event handler. Note these might be optionally missing in the HTML case.

Specified by:
endElement in interface ParserDelegate

endDocument

public void endDocument()
Fire endDocument event.

Specified by:
endDocument in interface ParserDelegate

comment

public void comment(HtmlParserVal lval)
comment handler Note, these are delegate to the XMLReader's LexicalHandler if any TODO: Check the property of the reader for its existance.

Specified by:
comment in interface ParserDelegate

startCDATA

public void startCDATA()
CDATA handler Note, these are delegate to the XMLReader's LexicalHandler if any This only marks the start boundary condition. Text still goes through characters()

Specified by:
startCDATA in interface ParserDelegate

endCDATA

public void endCDATA()
CDATA handler Note, these are delegate to the XMLReader's LexicalHandler if any This only marks the end boundary of the CDATA section. Text still goes through characters()

Specified by:
endCDATA in interface ParserDelegate

startDTD

public void startDTD(HtmlParserVal lval)
Start the beginning of the DOCTYPE (DTD) declaration Note, these are delegate to the XMLReader's LexicalHandler if any

Specified by:
startDTD in interface ParserDelegate
Parameters:
lval - HtmlParserVal represents the document type handle, system id or public id from the DOCTYPE declaration

endDTD

public void endDTD()
End the DOCTYPE declaration

Specified by:
endDTD in interface ParserDelegate

setXMLReader

public void setXMLReader(XMLReader reader)
used by the SaxParser to set itself in ParserDelegate

Specified by:
setXMLReader in interface ParserDelegate
Parameters:
reader - the XMLReader or really the current SAXParser


Copyright © 2007-2008. All Rights Reserved.