Package org.jsoup.parser
Class TreeBuilder
java.lang.Object
org.jsoup.parser.TreeBuilder
- Direct Known Subclasses:
HtmlTreeBuilder
,XmlTreeBuilder
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
protected Token
protected Document
private Token.EndTag
protected Parser
(package private) CharacterReader
protected ParseSettings
private Token.StartTag
(package private) Tokeniser
private boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Element
Get the current element (last on the stack).protected boolean
currentElementIs
(String normalName) Checks if the Current Element's normal name equals the supplied name.(package private) abstract ParseSettings
protected void
If the parser is tracking errors, add an error at the current position.protected void
If the parser is tracking errors, add an error at the current position.protected void
initialiseParse
(Reader input, String baseUri, Parser parser) protected boolean
isContentForTagData
(String normalName) (An internal method, visible for Element.(package private) abstract TreeBuilder
Create a new copy of this TreeBuilderprotected void
onNodeClosed
(Node node, Token token) Called by implementing TreeBuilders when a node is explicitly closed.protected void
onNodeInserted
(Node node, Token token) Called by implementing TreeBuilders when a node has been inserted.(package private) Document
parseFragment
(String inputFragment, Element context, String baseUri, Parser parser) protected abstract boolean
protected boolean
processEndTag
(String name) protected boolean
processStartTag
(String name) boolean
processStartTag
(String name, Attributes attrs) protected void
protected Tag
tagFor
(String tagName, ParseSettings settings) private void
trackNodePosition
(Node node, Token token, boolean start)
-
Field Details
-
parser
-
reader
CharacterReader reader -
tokeniser
Tokeniser tokeniser -
doc
-
stack
-
baseUri
-
currentToken
-
settings
-
seenTags
-
start
-
end
-
trackSourceRange
private boolean trackSourceRange
-
-
Constructor Details
-
TreeBuilder
TreeBuilder()
-
-
Method Details
-
defaultSettings
-
initialiseParse
-
parse
-
newInstance
Create a new copy of this TreeBuilder- Returns:
- copy, ready for a new parse
-
parseFragment
-
runParser
protected void runParser() -
process
-
processStartTag
-
processStartTag
-
processEndTag
-
currentElement
Get the current element (last on the stack). If all items have been removed, returns the document instead (which might not actually be on the stack; use stack.size() == 0 to test if required.- Returns:
- the last element on the stack, if any; or the root document
-
currentElementIs
Checks if the Current Element's normal name equals the supplied name.- Parameters:
normalName
- name to check- Returns:
- true if there is a current element on the stack, and its name equals the supplied
-
error
If the parser is tracking errors, add an error at the current position.- Parameters:
msg
- error message
-
error
If the parser is tracking errors, add an error at the current position.- Parameters:
msg
- error message templateargs
- template arguments
-
isContentForTagData
(An internal method, visible for Element. For HTML parse, signals that script and style text should be treated as Data Nodes). -
tagFor
-
onNodeInserted
Called by implementing TreeBuilders when a node has been inserted. This implementation includes optionally tracking the source range of the node.- Parameters:
node
- the node that was just insertedtoken
- the (optional) token that created this node
-
onNodeClosed
Called by implementing TreeBuilders when a node is explicitly closed. This implementation includes optionally tracking the closing source range of the node.- Parameters:
node
- the node being closedtoken
- the end-tag token that closed this node
-
trackNodePosition
-