nu.validator.htmlparser.test
Class TokenPrinter

java.lang.Object
  extended by nu.validator.htmlparser.test.TokenPrinter
All Implemented Interfaces:
TokenHandler, ErrorHandler

public class TokenPrinter
extends Object
implements TokenHandler, ErrorHandler


Field Summary
private  Writer writer
           
 
Constructor Summary
TokenPrinter(Writer writer)
           
 
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 error(SAXParseException exception)
           
 void fatalError(SAXParseException exception)
           
static void main(String[] args)
           
 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.
 void warning(SAXParseException exception)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

writer

private final Writer writer
Constructor Detail

TokenPrinter

public TokenPrinter(Writer writer)
Parameters:
writer -
Method Detail

characters

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

Specified by:
characters in interface TokenHandler
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)

comment

public void comment(char[] buf,
                    int length)
             throws SAXException
Description copied from interface: TokenHandler
Receive a comment token. The data is junk if the wantsComments() returned false.

Specified by:
comment in interface TokenHandler
Parameters:
buf - a buffer holding the data
length - the number of code units to read
Throws:
SAXException - if something went wrong

doctype

public void doctype(String name,
                    String publicIdentifier,
                    String systemIdentifier,
                    boolean correct)
             throws SAXException
Description copied from interface: TokenHandler
Receive a doctype token.

Specified by:
doctype in interface TokenHandler
Parameters:
name - the name
publicIdentifier - the public id
systemIdentifier - the system id
correct - whether the token is correct
Throws:
SAXException - if something went wrong

endTag

public void endTag(String name,
                   Attributes attributes)
            throws SAXException
Description copied from interface: TokenHandler
Receive an end tag token.

Specified by:
endTag in interface TokenHandler
Parameters:
name - the tag name
attributes - the attributes
Throws:
SAXException - if something went wrong

eof

public void eof()
         throws SAXException
Description copied from interface: TokenHandler
The end-of-file token.

Specified by:
eof in interface TokenHandler
Throws:
SAXException - if something went wrong

start

public void start(Tokenizer self)
           throws SAXException
Description copied from interface: TokenHandler
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.

Specified by:
start in interface TokenHandler
Parameters:
self - the Tokenizer.
Throws:
SAXException - if something went wrong

startTag

public void startTag(String name,
                     Attributes attributes)
              throws SAXException
Description copied from interface: TokenHandler
Receive a start tag token.

Specified by:
startTag in interface TokenHandler
Parameters:
name - the tag name
attributes - the attributes
Throws:
SAXException - if something went wrong

wantsComments

public boolean wantsComments()
                      throws SAXException
Description copied from interface: TokenHandler
If this handler implementation cares about comments, return true. If not, return false.

Specified by:
wantsComments in interface TokenHandler
Returns:
whether this handler wants comments
Throws:
SAXException - if something went wrong

main

public static void main(String[] args)
                 throws SAXException,
                        IOException
Throws:
SAXException
IOException

error

public void error(SAXParseException exception)
           throws SAXException
Specified by:
error in interface ErrorHandler
Throws:
SAXException

fatalError

public void fatalError(SAXParseException exception)
                throws SAXException
Specified by:
fatalError in interface ErrorHandler
Throws:
SAXException

warning

public void warning(SAXParseException exception)
             throws SAXException
Specified by:
warning in interface ErrorHandler
Throws:
SAXException