Package nu.validator.htmlparser.common
Interface TokenHandler
-
- All Known Implementing Classes:
CoalescingTreeBuilder
,TreeBuilder
public interface TokenHandler
Tokenizer
reports tokens through this interface.- Version:
- $Id$
- Author:
- hsivonen
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
cdataSectionAllowed()
Checks if the CDATA sections are allowed.void
characters(char[] buf, int start, int length)
Receive character tokens.void
comment(char[] buf, int start, int length)
Receive a comment token.void
doctype(java.lang.String name, java.lang.String publicIdentifier, java.lang.String systemIdentifier, boolean forceQuirks)
Receive a doctype token.void
endTag(ElementName eltName)
Receive an end tag token.void
endTokenization()
The perform final cleanup.void
eof()
The end-of-file token.void
startTag(ElementName eltName, HtmlAttributes attributes, boolean selfClosing)
Receive a start tag token.void
startTokenization(Tokenizer self)
This method is called at the start of tokenization before any other methods on this interface are called.boolean
wantsComments()
If this handler implementation cares about comments, returntrue
.void
zeroOriginatingReplacementCharacter()
Reports a U+0000 that's being turned into a U+FFFD.
-
-
-
Method Detail
-
startTokenization
void startTokenization(Tokenizer self) throws org.xml.sax.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 theTokenizer
in order to set the content model flag and in order to be able to query forLocator
data.- Parameters:
self
- theTokenizer
.- Throws:
org.xml.sax.SAXException
- if something went wrong
-
wantsComments
boolean wantsComments() throws org.xml.sax.SAXException
If this handler implementation cares about comments, returntrue
. If not, returnfalse
.- Returns:
- whether this handler wants comments
- Throws:
org.xml.sax.SAXException
- if something went wrong
-
doctype
void doctype(java.lang.String name, java.lang.String publicIdentifier, java.lang.String systemIdentifier, boolean forceQuirks) throws org.xml.sax.SAXException
Receive a doctype token.- Parameters:
name
- the namepublicIdentifier
- the public idsystemIdentifier
- the system idforceQuirks
- whether the token is correct- Throws:
org.xml.sax.SAXException
- if something went wrong
-
startTag
void startTag(ElementName eltName, HtmlAttributes attributes, boolean selfClosing) throws org.xml.sax.SAXException
Receive a start tag token.- Parameters:
eltName
- the tag nameattributes
- the attributesselfClosing
- TODO- Throws:
org.xml.sax.SAXException
- if something went wrong
-
endTag
void endTag(ElementName eltName) throws org.xml.sax.SAXException
Receive an end tag token.- Parameters:
eltName
- the tag name- Throws:
org.xml.sax.SAXException
- if something went wrong
-
comment
void comment(char[] buf, int start, int length) throws org.xml.sax.SAXException
Receive a comment token. The data is junk if thewantsComments()
returnedfalse
.- Parameters:
buf
- a buffer holding the datastart
- the offset into the bufferlength
- the number of code units to read- Throws:
org.xml.sax.SAXException
- if something went wrong
-
characters
void characters(char[] buf, int start, int length) throws org.xml.sax.SAXException
Receive character tokens. This method has the same semantics as the SAX method of the same name.- Parameters:
buf
- a buffer holding the datastart
- offset into the bufferlength
- the number of code units to read- Throws:
org.xml.sax.SAXException
- if something went wrong- See Also:
ContentHandler.characters(char[], int, int)
-
zeroOriginatingReplacementCharacter
void zeroOriginatingReplacementCharacter() throws org.xml.sax.SAXException
Reports a U+0000 that's being turned into a U+FFFD.- Throws:
org.xml.sax.SAXException
- if something went wrong
-
eof
void eof() throws org.xml.sax.SAXException
The end-of-file token.- Throws:
org.xml.sax.SAXException
- if something went wrong
-
endTokenization
void endTokenization() throws org.xml.sax.SAXException
The perform final cleanup.- Throws:
org.xml.sax.SAXException
- if something went wrong
-
cdataSectionAllowed
boolean cdataSectionAllowed() throws org.xml.sax.SAXException
Checks if the CDATA sections are allowed.- Returns:
true
if CDATA sections are allowed- Throws:
org.xml.sax.SAXException
- if something went wrong
-
-