Package org.jsoup.parser
Class TreeBuilder
java.lang.Object
org.jsoup.parser.TreeBuilder
- Direct Known Subclasses:
HtmlTreeBuilder,XmlTreeBuilder
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) String(package private) Token(package private) Documentprivate final Token.EndTagprotected Parser(package private) CharacterReader(package private) ParseSettingsprivate Token.StartTag(package private) Tokeniser(package private) boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) ElementGet the current element (last on the stack).(package private) booleancurrentElementIs(String normalName) Checks if the Current Element's normal name equals the supplied name, in the HTML namespace.(package private) booleancurrentElementIs(String normalName, String namespace) Checks if the Current Element's normal name equals the supplied name, in the specified namespace.(package private) StringGets the default namespace for this TreeBuilder(package private) abstract ParseSettings(package private) voidIf the parser is tracking errors, add an error at the current position.(package private) voidIf the parser is tracking errors, add an error at the current position.(package private) voidinitialiseParse(Reader input, String baseUri, Parser parser) (package private) booleanisContentForTagData(String normalName) (An internal method, visible for Element.(package private) abstract TreeBuilderCreate a new copy of this TreeBuilder(package private) voidonNodeClosed(Node node) Called by implementing TreeBuilders when a node is explicitly closed.(package private) voidonNodeInserted(Node node) Called by implementing TreeBuilders when a node has been inserted.(package private) DocumentparseFragment(String inputFragment, Element context, String baseUri, Parser parser) (package private) final Elementpop()Removes the last Element from the stack, hits onNodeClosed, and then returns it.(package private) abstract boolean(package private) booleanprocessEndTag(String name) (package private) booleanprocessStartTag(String name) (package private) booleanprocessStartTag(String name, Attributes attrs) (package private) final voidAdds the specified Element to the end of the stack, and hits onNodeInserted.(package private) void(package private) TagtagFor(String tagName, String namespace, ParseSettings settings) (package private) TagtagFor(String tagName, ParseSettings settings) private voidtrackNodePosition(Node node, boolean isStart)
-
Field Details
-
parser
-
reader
CharacterReader reader -
tokeniser
Tokeniser tokeniser -
doc
Document doc -
stack
-
baseUri
String baseUri -
currentToken
Token currentToken -
settings
ParseSettings settings -
seenTags
-
start
-
end
-
trackSourceRange
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
void runParser() -
process
-
processStartTag
-
processStartTag
-
processEndTag
-
pop
Removes the last Element from the stack, hits onNodeClosed, and then returns it.- Returns:
-
push
Adds the specified Element to the end of the stack, and hits onNodeInserted.- Parameters:
element-
-
currentElement
Element 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, in the HTML namespace.- Parameters:
normalName- name to check- Returns:
- true if there is a current element on the stack, and its name equals the supplied
-
currentElementIs
Checks if the Current Element's normal name equals the supplied name, in the specified namespace.- Parameters:
normalName- name to checknamespace- the namespace- 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
-
tagFor
-
defaultNamespace
String defaultNamespace()Gets the default namespace for this TreeBuilder- Returns:
- the default namespace
-
onNodeInserted
Called by implementing TreeBuilders when a node has been inserted. This implementation includes optionally tracking the source range of the node. @param node the node that was just inserted -
onNodeClosed
Called by implementing TreeBuilders when a node is explicitly closed. This implementation includes optionally tracking the closing source range of the node. @param node the node being closed -
trackNodePosition
-