public class Tokenizer
extends java.lang.Object
implements org.xml.sax.Locator
Locator interface. This is not an
incidental implementation detail: Users of this class are encouraged to make
use of the Locator nature.
By default, the tokenizer may report data that XML 1.0 bans. The tokenizer
can be configured to treat these conditions as fatal or to coerce the infoset
to something that XML 1.0 allows.| Constructor and Description |
|---|
Tokenizer(TokenHandler tokenHandler)
The constructor.
|
Tokenizer(TokenHandler tokenHandler,
boolean newAttributesEachTime) |
| Modifier and Type | Method and Description |
|---|---|
void |
becomeConfident() |
protected char |
checkChar(char[] buf,
int pos) |
void |
end() |
void |
eof() |
void |
err(java.lang.String message)
Reports a Parse Error.
|
protected void |
errAstralNonCharacter(int ch) |
protected void |
errAttributeValueMissing() |
protected void |
errBadCharAfterLt(char c) |
protected void |
errBadCharBeforeAttributeNameOrNull(char c) |
protected void |
errBogusComment() |
protected void |
errBogusDoctype() |
protected void |
errCharRefLacksSemicolon() |
protected void |
errDuplicateAttribute() |
protected void |
errEofAfterLt() |
protected void |
errEofInAttributeName() |
protected void |
errEofInAttributeValue() |
protected void |
errEofInComment() |
protected void |
errEofInDoctype() |
protected void |
errEofInEndTag() |
protected void |
errEofInPublicId() |
protected void |
errEofInSystemId() |
protected void |
errEofInTagName() |
protected void |
errEofWithoutGt() |
protected void |
errEqualsSignBeforeAttributeName() |
protected void |
errExpectedPublicId() |
protected void |
errExpectedSystemId() |
protected void |
errGarbageAfterLtSlash() |
protected void |
errGtInPublicId() |
protected void |
errGtInSystemId() |
protected void |
errHtml4LtSlashInRcdata(char folded) |
protected void |
errLtGt() |
protected void |
errLtOrEqualsOrGraveInUnquotedAttributeOrNull(char c) |
protected void |
errLtSlashGt() |
protected void |
errMissingSpaceBeforeDoctypeName() |
protected void |
errNamelessDoctype() |
protected void |
errNcrControlChar() |
protected char |
errNcrControlChar(char ch) |
protected void |
errNcrCr() |
protected void |
errNcrInC1Range() |
protected char |
errNcrNonCharacter(char ch) |
protected void |
errNcrOutOfRange() |
protected void |
errNcrSurrogate() |
protected void |
errNcrUnassigned() |
protected void |
errNcrZero() |
protected void |
errNestedComment() |
protected void |
errNoDigitsInNCR() |
protected void |
errNoNamedCharacterMatch() |
protected void |
errNoSpaceBetweenAttributes() |
protected void |
errNoSpaceBetweenDoctypePublicKeywordAndQuote() |
protected void |
errNoSpaceBetweenDoctypeSystemKeywordAndQuote() |
protected void |
errNoSpaceBetweenPublicAndSystemIds() |
protected void |
errNotSemicolonTerminated() |
protected void |
errPrematureEndOfComment() |
protected void |
errProcessingInstruction() |
protected void |
errQuoteBeforeAttributeName(char c) |
protected void |
errQuoteOrLtInAttributeNameOrNull(char c) |
protected void |
errSlashNotFollowedByGt() |
void |
errTreeBuilder(java.lang.String message) |
protected void |
errUnescapedAmpersandInterpretedAsCharacterReference() |
protected void |
errUnquotedAttributeValOrNull(char c) |
protected void |
errWarnLtSlashInRcdata() |
void |
fatal(java.lang.String message)
Reports an condition that would make the infoset incompatible with XML
1.0 as fatal.
|
protected void |
flushChars(char[] buf,
int pos)
Flushes coalesced character tokens.
|
int |
getCol()
Returns the col.
|
int |
getColumnNumber() |
org.xml.sax.ErrorHandler |
getErrorHandler() |
int |
getLine()
Returns the line.
|
int |
getLineNumber() |
java.lang.String |
getPublicId() |
java.lang.String |
getSystemId() |
void |
initializeWithoutStarting() |
void |
initLocation(java.lang.String newPublicId,
java.lang.String newSystemId) |
boolean |
internalEncodingDeclaration(java.lang.String internalCharset) |
boolean |
isInDataState() |
boolean |
isMappingLangToXmlLang()
Returns the mappingLangToXmlLang.
|
boolean |
isNextCharOnNewLine()
Returns the nextCharOnNewLine.
|
boolean |
isPrevCR() |
void |
loadState(Tokenizer other) |
protected void |
maybeErrAttributesOnEndTag(HtmlAttributes attrs) |
protected void |
maybeErrSlashInEndTag(boolean selfClosing) |
protected void |
maybeWarnPrivateUse(char ch) |
protected void |
maybeWarnPrivateUseAstral() |
protected void |
noteAttributeWithoutValue() |
protected void |
noteUnquotedAttributeValue() |
void |
notifyAboutMetaBoundary() |
void |
requestSuspension() |
void |
resetToDataState() |
void |
setCommentPolicy(XmlViolationPolicy commentPolicy)
Sets the commentPolicy.
|
void |
setContentNonXmlCharPolicy(XmlViolationPolicy contentNonXmlCharPolicy)
Sets the contentNonXmlCharPolicy.
|
void |
setContentSpacePolicy(XmlViolationPolicy contentSpacePolicy)
Sets the contentSpacePolicy.
|
void |
setEncodingDeclarationHandler(EncodingDeclarationHandler encodingDeclarationHandler)
Sets the encodingDeclarationHandler.
|
void |
setErrorHandler(org.xml.sax.ErrorHandler eh)
Sets the error handler.
|
void |
setInterner(Interner interner) |
void |
setLineNumber(int line)
For C++ use only.
|
void |
setMappingLangToXmlLang(boolean mappingLangToXmlLang)
Sets the mappingLangToXmlLang.
|
void |
setNamePolicy(XmlViolationPolicy namePolicy) |
void |
setStateAndEndTagExpectation(int specialTokenizerState,
ElementName endTagExpectation)
Sets the tokenizer state and the associated element name.
|
void |
setStateAndEndTagExpectation(int specialTokenizerState,
java.lang.String endTagExpectation)
Sets the tokenizer state and the associated element name.
|
void |
setTransitionBaseOffset(int offset)
Sets an offset to be added to the position reported to
TransitionHandler. |
void |
setXmlnsPolicy(XmlViolationPolicy xmlnsPolicy)
Sets the xmlnsPolicy.
|
protected void |
silentCarriageReturn() |
protected void |
silentLineFeed() |
void |
start() |
protected void |
startErrorReporting() |
protected java.lang.String |
strBufToString()
The buffer as a String.
|
boolean |
tokenizeBuffer(UTF16Buffer buffer) |
protected int |
transition(int from,
int to,
boolean reconsume,
int pos) |
void |
warn(java.lang.String message)
Reports a warning
|
public static final int DATA
public static final int RCDATA
public static final int SCRIPT_DATA
public static final int RAWTEXT
public static final int SCRIPT_DATA_ESCAPED
public static final int ATTRIBUTE_VALUE_DOUBLE_QUOTED
public static final int ATTRIBUTE_VALUE_SINGLE_QUOTED
public static final int ATTRIBUTE_VALUE_UNQUOTED
public static final int PLAINTEXT
public static final int TAG_OPEN
public static final int CLOSE_TAG_OPEN
public static final int TAG_NAME
public static final int BEFORE_ATTRIBUTE_NAME
public static final int ATTRIBUTE_NAME
public static final int AFTER_ATTRIBUTE_NAME
public static final int BEFORE_ATTRIBUTE_VALUE
public static final int AFTER_ATTRIBUTE_VALUE_QUOTED
public static final int BOGUS_COMMENT
public static final int MARKUP_DECLARATION_OPEN
public static final int DOCTYPE
public static final int BEFORE_DOCTYPE_NAME
public static final int DOCTYPE_NAME
public static final int AFTER_DOCTYPE_NAME
public static final int BEFORE_DOCTYPE_PUBLIC_IDENTIFIER
public static final int DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED
public static final int DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED
public static final int AFTER_DOCTYPE_PUBLIC_IDENTIFIER
public static final int BEFORE_DOCTYPE_SYSTEM_IDENTIFIER
public static final int DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED
public static final int DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED
public static final int AFTER_DOCTYPE_SYSTEM_IDENTIFIER
public static final int BOGUS_DOCTYPE
public static final int COMMENT_START
public static final int COMMENT_START_DASH
public static final int COMMENT
public static final int COMMENT_END_DASH
public static final int COMMENT_END
public static final int COMMENT_END_BANG
public static final int NON_DATA_END_TAG_NAME
public static final int MARKUP_DECLARATION_HYPHEN
public static final int MARKUP_DECLARATION_OCTYPE
public static final int DOCTYPE_UBLIC
public static final int DOCTYPE_YSTEM
public static final int AFTER_DOCTYPE_PUBLIC_KEYWORD
public static final int BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS
public static final int AFTER_DOCTYPE_SYSTEM_KEYWORD
public static final int CONSUME_CHARACTER_REFERENCE
public static final int CONSUME_NCR
public static final int CHARACTER_REFERENCE_TAIL
public static final int HEX_NCR_LOOP
public static final int DECIMAL_NRC_LOOP
public static final int HANDLE_NCR_VALUE
public static final int HANDLE_NCR_VALUE_RECONSUME
public static final int CHARACTER_REFERENCE_HILO_LOOKUP
public static final int SELF_CLOSING_START_TAG
public static final int CDATA_START
public static final int CDATA_SECTION
public static final int CDATA_RSQB
public static final int CDATA_RSQB_RSQB
public static final int SCRIPT_DATA_LESS_THAN_SIGN
public static final int SCRIPT_DATA_ESCAPE_START
public static final int SCRIPT_DATA_ESCAPE_START_DASH
public static final int SCRIPT_DATA_ESCAPED_DASH
public static final int SCRIPT_DATA_ESCAPED_DASH_DASH
public static final int BOGUS_COMMENT_HYPHEN
public static final int RAWTEXT_RCDATA_LESS_THAN_SIGN
public static final int SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN
public static final int SCRIPT_DATA_DOUBLE_ESCAPE_START
public static final int SCRIPT_DATA_DOUBLE_ESCAPED
public static final int SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN
public static final int SCRIPT_DATA_DOUBLE_ESCAPED_DASH
public static final int SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH
public static final int SCRIPT_DATA_DOUBLE_ESCAPE_END
public static final int PROCESSING_INSTRUCTION
public static final int PROCESSING_INSTRUCTION_QUESTION_MARK
public static final int AMBIGUOUS_AMPERSAND
public static final int COMMENT_LESSTHAN
public static final int COMMENT_LESSTHAN_BANG
public static final int COMMENT_LESSTHAN_BANG_DASH
public static final int COMMENT_LESSTHAN_BANG_DASH_DASH
protected final TokenHandler tokenHandler
protected EncodingDeclarationHandler encodingDeclarationHandler
protected org.xml.sax.ErrorHandler errorHandler
protected boolean lastCR
protected int stateSave
protected int index
protected int value
protected int cstart
protected ElementName endTagExpectation
protected boolean endTag
true if tokenizing an end tagprotected AttributeName attributeName
protected boolean confident
protected LocatorImpl ampersandLocation
public Tokenizer(TokenHandler tokenHandler, boolean newAttributesEachTime)
public Tokenizer(TokenHandler tokenHandler)
tokenHandler - the handler for receiving tokenspublic void setInterner(Interner interner)
public void initLocation(java.lang.String newPublicId,
java.lang.String newSystemId)
public boolean isMappingLangToXmlLang()
public void setMappingLangToXmlLang(boolean mappingLangToXmlLang)
mappingLangToXmlLang - the mappingLangToXmlLang to setpublic void setErrorHandler(org.xml.sax.ErrorHandler eh)
XMLReader.setErrorHandler(org.xml.sax.ErrorHandler)public org.xml.sax.ErrorHandler getErrorHandler()
public void setCommentPolicy(XmlViolationPolicy commentPolicy)
commentPolicy - the commentPolicy to setpublic void setContentNonXmlCharPolicy(XmlViolationPolicy contentNonXmlCharPolicy)
contentNonXmlCharPolicy - the contentNonXmlCharPolicy to setpublic void setContentSpacePolicy(XmlViolationPolicy contentSpacePolicy)
contentSpacePolicy - the contentSpacePolicy to setpublic void setXmlnsPolicy(XmlViolationPolicy xmlnsPolicy)
xmlnsPolicy - the xmlnsPolicy to setpublic void setNamePolicy(XmlViolationPolicy namePolicy)
public void setStateAndEndTagExpectation(int specialTokenizerState,
java.lang.String endTagExpectation)
specialTokenizerState - the tokenizer state to setendTagExpectation - the expected end tag for transitioning back to normalpublic void setStateAndEndTagExpectation(int specialTokenizerState,
ElementName endTagExpectation)
specialTokenizerState - the tokenizer state to setendTagExpectation - the expected end tag for transitioning back to normalpublic void setLineNumber(int line)
public int getLineNumber()
getLineNumber in interface org.xml.sax.LocatorLocator.getLineNumber()public int getColumnNumber()
getColumnNumber in interface org.xml.sax.LocatorLocator.getColumnNumber()public java.lang.String getPublicId()
getPublicId in interface org.xml.sax.LocatorLocator.getPublicId()public java.lang.String getSystemId()
getSystemId in interface org.xml.sax.LocatorLocator.getSystemId()public void notifyAboutMetaBoundary()
protected java.lang.String strBufToString()
C++ memory note: The return value must be released.
protected void flushChars(char[] buf,
int pos)
throws org.xml.sax.SAXException
buf - TODOpos - TODOorg.xml.sax.SAXExceptionpublic void fatal(java.lang.String message)
throws org.xml.sax.SAXException
message - the messageorg.xml.sax.SAXExceptionorg.xml.sax.SAXParseExceptionpublic void err(java.lang.String message)
throws org.xml.sax.SAXException
message - the messageorg.xml.sax.SAXExceptionpublic void errTreeBuilder(java.lang.String message)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionpublic void warn(java.lang.String message)
throws org.xml.sax.SAXException
message - the messageorg.xml.sax.SAXExceptionprotected void startErrorReporting()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionpublic void start()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionpublic boolean tokenizeBuffer(UTF16Buffer buffer) throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected int transition(int from,
int to,
boolean reconsume,
int pos)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void silentCarriageReturn()
protected void silentLineFeed()
public void eof()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected char checkChar(char[] buf,
int pos)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionpublic boolean internalEncodingDeclaration(java.lang.String internalCharset)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionpublic void end()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionpublic void requestSuspension()
public void becomeConfident()
public boolean isNextCharOnNewLine()
public boolean isPrevCR()
public int getLine()
public int getCol()
public boolean isInDataState()
public void resetToDataState()
public void loadState(Tokenizer other) throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionpublic void initializeWithoutStarting()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errGarbageAfterLtSlash()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errLtSlashGt()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errWarnLtSlashInRcdata()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errHtml4LtSlashInRcdata(char folded)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errCharRefLacksSemicolon()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errNoDigitsInNCR()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errGtInSystemId()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errGtInPublicId()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errNamelessDoctype()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errNestedComment()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errPrematureEndOfComment()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errBogusComment()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errUnquotedAttributeValOrNull(char c)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errSlashNotFollowedByGt()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errNoSpaceBetweenAttributes()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errLtOrEqualsOrGraveInUnquotedAttributeOrNull(char c)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errAttributeValueMissing()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errBadCharBeforeAttributeNameOrNull(char c)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errEqualsSignBeforeAttributeName()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errBadCharAfterLt(char c)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errLtGt()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errProcessingInstruction()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errUnescapedAmpersandInterpretedAsCharacterReference()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errNotSemicolonTerminated()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errNoNamedCharacterMatch()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errQuoteBeforeAttributeName(char c)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errQuoteOrLtInAttributeNameOrNull(char c)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errExpectedPublicId()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errBogusDoctype()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void maybeWarnPrivateUseAstral()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void maybeWarnPrivateUse(char ch)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void maybeErrAttributesOnEndTag(HtmlAttributes attrs) throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void maybeErrSlashInEndTag(boolean selfClosing)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected char errNcrNonCharacter(char ch)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errAstralNonCharacter(int ch)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errNcrSurrogate()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected char errNcrControlChar(char ch)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errNcrCr()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errNcrInC1Range()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errEofInPublicId()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errEofInComment()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errEofInDoctype()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errEofInAttributeValue()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errEofInAttributeName()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errEofWithoutGt()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errEofInTagName()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errEofInEndTag()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errEofAfterLt()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errNcrOutOfRange()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errNcrUnassigned()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errDuplicateAttribute()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errEofInSystemId()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errExpectedSystemId()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errMissingSpaceBeforeDoctypeName()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errNcrControlChar()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errNcrZero()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errNoSpaceBetweenDoctypeSystemKeywordAndQuote()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errNoSpaceBetweenPublicAndSystemIds()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void errNoSpaceBetweenDoctypePublicKeywordAndQuote()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void noteAttributeWithoutValue()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprotected void noteUnquotedAttributeValue()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionpublic void setEncodingDeclarationHandler(EncodingDeclarationHandler encodingDeclarationHandler)
encodingDeclarationHandler - the encodingDeclarationHandler to setpublic void setTransitionBaseOffset(int offset)
TransitionHandler.offset - the offset