public abstract class TreeBuilder<T> extends Object implements TokenHandler, TreeBuilderState<T>
Modifier and Type | Field and Description |
---|---|
protected char[] |
charBuffer |
protected int |
charBufferLen |
protected ErrorHandler |
errorHandler |
protected Tokenizer |
tokenizer |
Modifier | Constructor and Description |
---|---|
protected |
TreeBuilder() |
Modifier and Type | Method and Description |
---|---|
protected void |
accumulateCharacters(char[] buf,
int start,
int length) |
protected abstract void |
addAttributesToElement(T element,
HtmlAttributes attributes) |
protected abstract void |
appendCharacters(T parent,
char[] buf,
int start,
int length) |
protected abstract void |
appendChildrenToNewParent(T oldParent,
T newParent) |
protected abstract void |
appendComment(T parent,
char[] buf,
int start,
int length) |
protected abstract void |
appendCommentToDocument(char[] buf,
int start,
int length) |
protected void |
appendDoctypeToDocument(String name,
String publicIdentifier,
String systemIdentifier) |
protected abstract void |
appendElement(T child,
T newParent) |
protected abstract void |
appendIsindexPrompt(T parent) |
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.
|
protected abstract T |
createElement(String ns,
String name,
HtmlAttributes attributes) |
protected T |
createElement(String ns,
String name,
HtmlAttributes attributes,
T form) |
protected abstract T |
createHtmlElementSetAsRoot(HtmlAttributes attributes) |
protected T |
currentNode() |
protected abstract void |
detachFromParent(T element) |
void |
doctype(String name,
String publicIdentifier,
String systemIdentifier,
boolean forceQuirks)
Receive a doctype token.
|
protected void |
documentMode(DocumentMode m,
String publicIdentifier,
String systemIdentifier,
boolean html4SpecificAdditionalErrorChecks) |
protected void |
elementPopped(String ns,
String name,
T node) |
protected void |
elementPushed(String ns,
String name,
T node) |
protected void |
end() |
void |
endTag(ElementName elementName)
Receive an end tag token.
|
void |
endTokenization()
The perform final cleanup.
|
void |
eof()
The end-of-file token.
|
static String |
extractCharsetFromContent(String attributeValue)
C++ memory note: The return value must be released.
|
protected void |
fatal()
Reports an condition that would make the infoset incompatible with XML
1.0 as fatal.
|
protected void |
fatal(Exception e) |
void |
flushCharacters()
Flushes the pending characters.
|
T |
getDeepTreeSurrogateParent()
Returns the deepTreeSurrogateParent.
|
ErrorHandler |
getErrorHandler()
Returns the errorHandler.
|
T |
getFormPointer()
Returns the formPointer.
|
T |
getHeadPointer()
Returns the headPointer.
|
nu.validator.htmlparser.impl.StackNode<T>[] |
getListOfActiveFormattingElements()
Returns the listOfActiveFormattingElements.
|
int |
getListOfActiveFormattingElementsLength()
Return the length of the list of active formatting elements.
|
int |
getMode()
Returns the mode.
|
int |
getOriginalMode()
Returns the originalMode.
|
nu.validator.htmlparser.impl.StackNode<T>[] |
getStack()
Returns the stack.
|
int |
getStackLength()
Return the length of the stack.
|
protected abstract boolean |
hasChildren(T element) |
protected abstract void |
insertFosterParentedCharacters(char[] buf,
int start,
int length,
T table,
T stackParent) |
protected abstract void |
insertFosterParentedChild(T child,
T table,
T stackParent) |
boolean |
isFramesetOk()
Returns the framesetOk.
|
boolean |
isNeedToDropLF()
Returns the needToDropLF.
|
boolean |
isQuirks()
Returns the quirks.
|
boolean |
isScriptingEnabled()
Returns the scriptingEnabled.
|
void |
loadState(TreeBuilderState<T> snapshot,
Interner interner) |
protected void |
markMalformedIfScript(T elt) |
TreeBuilderState<T> |
newSnapshot()
Creates a comparable snapshot of the tree builder state.
|
protected void |
requestSuspension() |
void |
setDoctypeExpectation(DoctypeExpectation doctypeExpectation)
Sets the doctypeExpectation.
|
void |
setDocumentModeHandler(DocumentModeHandler documentModeHandler)
Sets the documentModeHandler.
|
void |
setErrorHandler(ErrorHandler errorHandler)
Sets the errorHandler.
|
void |
setFragmentContext(String context)
The argument MUST be an interned string or
null . |
void |
setFragmentContext(String context,
String ns,
T node,
boolean quirks)
The argument MUST be an interned string or
null . |
void |
setIgnoringComments(boolean ignoreComments) |
void |
setNamePolicy(XmlViolationPolicy namePolicy) |
void |
setReportingDoctype(boolean reportingDoctype)
Sets the reportingDoctype.
|
void |
setScriptingEnabled(boolean scriptingEnabled)
Sets the scriptingEnabled.
|
boolean |
snapshotMatches(TreeBuilderState<T> snapshot) |
protected void |
start(boolean fragmentMode) |
void |
startTag(ElementName elementName,
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, return
true . |
void |
zeroOriginatingReplacementCharacter()
Reports a U+0000 that's being turned into a U+FFFD.
|
protected Tokenizer tokenizer
protected ErrorHandler errorHandler
protected char[] charBuffer
protected int charBufferLen
protected void fatal() throws SAXException
SAXException
SAXParseException
protected final void fatal(Exception e) throws SAXException
SAXException
public final void startTokenization(Tokenizer self) throws SAXException
TokenHandler
Tokenizer
in order to set the content
model flag and in order to be able to query for Locator
data.startTokenization
in interface TokenHandler
self
- the Tokenizer
.SAXException
- if something went wrongpublic final void doctype(String name, String publicIdentifier, String systemIdentifier, boolean forceQuirks) throws SAXException
TokenHandler
doctype
in interface TokenHandler
name
- the namepublicIdentifier
- the public idsystemIdentifier
- the system idforceQuirks
- whether the token is correctSAXException
- if something went wrongpublic final void comment(char[] buf, int start, int length) throws SAXException
TokenHandler
wantsComments()
returned false
.comment
in interface TokenHandler
buf
- a buffer holding the datastart
- the offset into the bufferlength
- the number of code units to readSAXException
- if something went wrongpublic final void characters(char[] buf, int start, int length) throws SAXException
TokenHandler
characters
in interface TokenHandler
buf
- a buffer holding the datastart
- offset into the bufferlength
- the number of code units to readSAXException
- if something went wrongTokenHandler.characters(char[], int,
int)
public void zeroOriginatingReplacementCharacter() throws SAXException
TokenHandler
zeroOriginatingReplacementCharacter
in interface TokenHandler
SAXException
- if something went wrongTokenHandler.zeroOriginatingReplacementCharacter()
public final void eof() throws SAXException
TokenHandler
eof
in interface TokenHandler
SAXException
- if something went wrongpublic final void endTokenization() throws SAXException
TokenHandler
endTokenization
in interface TokenHandler
SAXException
- if something went wrongTokenHandler.endTokenization()
public final void startTag(ElementName elementName, HtmlAttributes attributes, boolean selfClosing) throws SAXException
TokenHandler
startTag
in interface TokenHandler
elementName
- the tag nameattributes
- the attributesselfClosing
- TODOSAXException
- if something went wrongpublic static String extractCharsetFromContent(String attributeValue)
C++ memory note: The return value must be released.
SAXException
StopSniffingException
public final void endTag(ElementName elementName) throws SAXException
TokenHandler
endTag
in interface TokenHandler
elementName
- the tag nameSAXException
- if something went wrongprotected void accumulateCharacters(char[] buf, int start, int length) throws SAXException
SAXException
protected final void requestSuspension()
protected abstract T createElement(String ns, String name, HtmlAttributes attributes) throws SAXException
SAXException
protected T createElement(String ns, String name, HtmlAttributes attributes, T form) throws SAXException
SAXException
protected abstract T createHtmlElementSetAsRoot(HtmlAttributes attributes) throws SAXException
SAXException
protected abstract void detachFromParent(T element) throws SAXException
SAXException
protected abstract boolean hasChildren(T element) throws SAXException
SAXException
protected abstract void appendElement(T child, T newParent) throws SAXException
SAXException
protected abstract void appendChildrenToNewParent(T oldParent, T newParent) throws SAXException
SAXException
protected abstract void insertFosterParentedChild(T child, T table, T stackParent) throws SAXException
SAXException
protected abstract void insertFosterParentedCharacters(char[] buf, int start, int length, T table, T stackParent) throws SAXException
SAXException
protected abstract void appendCharacters(T parent, char[] buf, int start, int length) throws SAXException
SAXException
protected abstract void appendIsindexPrompt(T parent) throws SAXException
SAXException
protected abstract void appendComment(T parent, char[] buf, int start, int length) throws SAXException
SAXException
protected abstract void appendCommentToDocument(char[] buf, int start, int length) throws SAXException
SAXException
protected abstract void addAttributesToElement(T element, HtmlAttributes attributes) throws SAXException
SAXException
protected void markMalformedIfScript(T elt) throws SAXException
SAXException
protected void start(boolean fragmentMode) throws SAXException
SAXException
protected void end() throws SAXException
SAXException
protected void appendDoctypeToDocument(String name, String publicIdentifier, String systemIdentifier) throws SAXException
SAXException
protected void elementPushed(String ns, String name, T node) throws SAXException
SAXException
protected void elementPopped(String ns, String name, T node) throws SAXException
SAXException
protected void documentMode(DocumentMode m, String publicIdentifier, String systemIdentifier, boolean html4SpecificAdditionalErrorChecks) throws SAXException
SAXException
public boolean wantsComments()
TokenHandler
true
. If not, return false
.wantsComments
in interface TokenHandler
TokenHandler.wantsComments()
public void setIgnoringComments(boolean ignoreComments)
public final void setErrorHandler(ErrorHandler errorHandler)
errorHandler
- the errorHandler to setpublic ErrorHandler getErrorHandler()
public final void setFragmentContext(String context)
null
.context
- public boolean cdataSectionAllowed() throws SAXException
TokenHandler
cdataSectionAllowed
in interface TokenHandler
true
if CDATA sections are allowedSAXException
- if something went wrongTokenHandler.cdataSectionAllowed()
public final void setFragmentContext(String context, String ns, T node, boolean quirks)
null
.context
- protected final T currentNode()
public boolean isScriptingEnabled()
public void setScriptingEnabled(boolean scriptingEnabled)
scriptingEnabled
- the scriptingEnabled to setpublic void setDoctypeExpectation(DoctypeExpectation doctypeExpectation)
doctypeExpectation
- the doctypeExpectation to setpublic void setNamePolicy(XmlViolationPolicy namePolicy)
public void setDocumentModeHandler(DocumentModeHandler documentModeHandler)
documentModeHandler
- the documentModeHandler to setpublic void setReportingDoctype(boolean reportingDoctype)
reportingDoctype
- the reportingDoctype to setpublic final void flushCharacters() throws SAXException
SAXException
public TreeBuilderState<T> newSnapshot() throws SAXException
delete
on the returned object.SAXException
public boolean snapshotMatches(TreeBuilderState<T> snapshot)
public void loadState(TreeBuilderState<T> snapshot, Interner interner) throws SAXException
SAXException
public T getFormPointer()
TreeBuilderState
getFormPointer
in interface TreeBuilderState<T>
TreeBuilderState.getFormPointer()
public T getHeadPointer()
getHeadPointer
in interface TreeBuilderState<T>
public T getDeepTreeSurrogateParent()
getDeepTreeSurrogateParent
in interface TreeBuilderState<T>
public nu.validator.htmlparser.impl.StackNode<T>[] getListOfActiveFormattingElements()
TreeBuilderState
getListOfActiveFormattingElements
in interface TreeBuilderState<T>
TreeBuilderState.getListOfActiveFormattingElements()
public nu.validator.htmlparser.impl.StackNode<T>[] getStack()
TreeBuilderState
getStack
in interface TreeBuilderState<T>
TreeBuilderState.getStack()
public int getMode()
getMode
in interface TreeBuilderState<T>
public int getOriginalMode()
getOriginalMode
in interface TreeBuilderState<T>
public boolean isFramesetOk()
isFramesetOk
in interface TreeBuilderState<T>
public boolean isNeedToDropLF()
isNeedToDropLF
in interface TreeBuilderState<T>
public boolean isQuirks()
isQuirks
in interface TreeBuilderState<T>
public int getListOfActiveFormattingElementsLength()
TreeBuilderState
getListOfActiveFormattingElementsLength
in interface TreeBuilderState<T>
TreeBuilderState.getListOfActiveFormattingElementsLength()
public int getStackLength()
TreeBuilderState
getStackLength
in interface TreeBuilderState<T>
TreeBuilderState.getStackLength()
Copyright © 2017. All rights reserved.