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
SAXExceptionSAXParseExceptionprotected final void fatal(Exception e) throws SAXException
SAXExceptionpublic final void startTokenization(Tokenizer self) throws SAXException
TokenHandlerTokenizer in order to set the content
model flag and in order to be able to query for Locator
data.startTokenization in interface TokenHandlerself - the Tokenizer.SAXException - if something went wrongpublic final void doctype(String name, String publicIdentifier, String systemIdentifier, boolean forceQuirks) throws SAXException
TokenHandlerdoctype in interface TokenHandlername - 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
TokenHandlerwantsComments() returned false.comment in interface TokenHandlerbuf - 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
TokenHandlercharacters in interface TokenHandlerbuf - 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
TokenHandlerzeroOriginatingReplacementCharacter in interface TokenHandlerSAXException - if something went wrongTokenHandler.zeroOriginatingReplacementCharacter()public final void eof()
throws SAXException
TokenHandlereof in interface TokenHandlerSAXException - if something went wrongpublic final void endTokenization()
throws SAXException
TokenHandlerendTokenization in interface TokenHandlerSAXException - if something went wrongTokenHandler.endTokenization()public final void startTag(ElementName elementName, HtmlAttributes attributes, boolean selfClosing) throws SAXException
TokenHandlerstartTag in interface TokenHandlerelementName - the tag nameattributes - the attributesselfClosing - TODOSAXException - if something went wrongpublic static String extractCharsetFromContent(String attributeValue)
C++ memory note: The return value must be released.
SAXExceptionStopSniffingExceptionpublic final void endTag(ElementName elementName) throws SAXException
TokenHandlerendTag in interface TokenHandlerelementName - the tag nameSAXException - if something went wrongprotected void accumulateCharacters(char[] buf,
int start,
int length)
throws SAXException
SAXExceptionprotected final void requestSuspension()
protected abstract T createElement(String ns, String name, HtmlAttributes attributes) throws SAXException
SAXExceptionprotected T createElement(String ns, String name, HtmlAttributes attributes, T form) throws SAXException
SAXExceptionprotected abstract T createHtmlElementSetAsRoot(HtmlAttributes attributes) throws SAXException
SAXExceptionprotected abstract void detachFromParent(T element) throws SAXException
SAXExceptionprotected abstract boolean hasChildren(T element) throws SAXException
SAXExceptionprotected abstract void appendElement(T child, T newParent) throws SAXException
SAXExceptionprotected abstract void appendChildrenToNewParent(T oldParent, T newParent) throws SAXException
SAXExceptionprotected abstract void insertFosterParentedChild(T child, T table, T stackParent) throws SAXException
SAXExceptionprotected abstract void insertFosterParentedCharacters(char[] buf,
int start,
int length,
T table,
T stackParent)
throws SAXException
SAXExceptionprotected abstract void appendCharacters(T parent, char[] buf, int start, int length) throws SAXException
SAXExceptionprotected abstract void appendIsindexPrompt(T parent) throws SAXException
SAXExceptionprotected abstract void appendComment(T parent, char[] buf, int start, int length) throws SAXException
SAXExceptionprotected abstract void appendCommentToDocument(char[] buf,
int start,
int length)
throws SAXException
SAXExceptionprotected abstract void addAttributesToElement(T element, HtmlAttributes attributes) throws SAXException
SAXExceptionprotected void markMalformedIfScript(T elt) throws SAXException
SAXExceptionprotected void start(boolean fragmentMode)
throws SAXException
SAXExceptionprotected void end()
throws SAXException
SAXExceptionprotected void appendDoctypeToDocument(String name, String publicIdentifier, String systemIdentifier) throws SAXException
SAXExceptionprotected void elementPushed(String ns, String name, T node) throws SAXException
SAXExceptionprotected void elementPopped(String ns, String name, T node) throws SAXException
SAXExceptionprotected void documentMode(DocumentMode m, String publicIdentifier, String systemIdentifier, boolean html4SpecificAdditionalErrorChecks) throws SAXException
SAXExceptionpublic boolean wantsComments()
TokenHandlertrue. If not, return false.wantsComments in interface TokenHandlerTokenHandler.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
TokenHandlercdataSectionAllowed in interface TokenHandlertrue 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
SAXExceptionpublic TreeBuilderState<T> newSnapshot() throws SAXException
delete on the returned object.SAXExceptionpublic boolean snapshotMatches(TreeBuilderState<T> snapshot)
public void loadState(TreeBuilderState<T> snapshot, Interner interner) throws SAXException
SAXExceptionpublic T getFormPointer()
TreeBuilderStategetFormPointer 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()
TreeBuilderStategetListOfActiveFormattingElements in interface TreeBuilderState<T>TreeBuilderState.getListOfActiveFormattingElements()public nu.validator.htmlparser.impl.StackNode<T>[] getStack()
TreeBuilderStategetStack 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()
TreeBuilderStategetListOfActiveFormattingElementsLength in interface TreeBuilderState<T>TreeBuilderState.getListOfActiveFormattingElementsLength()public int getStackLength()
TreeBuilderStategetStackLength in interface TreeBuilderState<T>TreeBuilderState.getStackLength()Copyright © 2024. All rights reserved.