nu.validator.htmlparser.impl
Interface TokenHandler

All Known Implementing Classes:
DOMTreeBuilder, JSONArrayTokenHandler, SAXStreamer, SAXTreeBuilder, TokenPrinter, TreeBuilder, XOMTreeBuilder

public interface TokenHandler

Tokenizer reports tokens through this interface.

Version:
$Id: TokenHandler.java 150 2007-08-16 19:21:25Z hsivonen $
Author:
hsivonen

Method Summary
 void characters(char[] buf, int start, int length)
          Receive character tokens.
 void comment(char[] buf, int length)
          Receive a comment token.
 void doctype(String name, String publicIdentifier, String systemIdentifier, boolean correct)
          Receive a doctype token.
 void endTag(String name, Attributes attributes)
          Receive an end tag token.
 void eof()
          The end-of-file token.
 void start(Tokenizer self)
          This method is called at the start of tokenization before any other methods on this interface are called.
 void startTag(String name, Attributes attributes)
          Receive a start tag token.
 boolean wantsComments()
          If this handler implementation cares about comments, return true.
 

Method Detail

start

void start(Tokenizer self)
           throws SAXException
This method is called at the start of tokenization before any other methods on this interface are called. Implementations should hold the reference to the Tokenizer in order to set the content model flag and in order to be able to query for Locator data.

Parameters:
self - the Tokenizer.
Throws:
SAXException - if something went wrong

wantsComments

boolean wantsComments()
                      throws SAXException
If this handler implementation cares about comments, return true. If not, return false.

Returns:
whether this handler wants comments
Throws:
SAXException - if something went wrong

doctype

void doctype(String name,
             String publicIdentifier,
             String systemIdentifier,
             boolean correct)
             throws SAXException
Receive a doctype token.

Parameters:
name - the name
publicIdentifier - the public id
systemIdentifier - the system id
correct - whether the token is correct
Throws:
SAXException - if something went wrong

startTag

void startTag(String name,
              Attributes attributes)
              throws SAXException
Receive a start tag token.

Parameters:
name - the tag name
attributes - the attributes
Throws:
SAXException - if something went wrong

endTag

void endTag(String name,
            Attributes attributes)
            throws SAXException
Receive an end tag token.

Parameters:
name - the tag name
attributes - the attributes
Throws:
SAXException - if something went wrong

comment

void comment(char[] buf,
             int length)
             throws SAXException
Receive a comment token. The data is junk if the wantsComments() returned false.

Parameters:
buf - a buffer holding the data
length - the number of code units to read
Throws:
SAXException - if something went wrong

characters

void characters(char[] buf,
                int start,
                int length)
                throws SAXException
Receive character tokens. This method has the same semantics as the SAX method of the same name.

Parameters:
buf - a buffer holding the data
start - offset into the buffer
length - the number of code units to read
Throws:
SAXException - if something went wrong
See Also:
ContentHandler.characters(char[], int, int)

eof

void eof()
         throws SAXException
The end-of-file token.

Throws:
SAXException - if something went wrong