Package org.htmlunit.html
Class HtmlDomTreeWalker
java.lang.Object
org.htmlunit.html.HtmlDomTreeWalker
In general this is an implementation of org.w3c.dom.traversal.TreeWalker.
The class org.w3c.dom.traversal.TreeWalker is not available on Android
therefore we have this impl as backend.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionHtmlDomTreeWalker
(DomNode root, int whatToShow, org.w3c.dom.traversal.NodeFilter filter, boolean expandEntityReferences) Creates an instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate short
acceptNode
(Node n) Test whether a specified node is visible in the logical view of a TreeWalker, based solely on the whatToShow constant.private DomNode
getEquivalentLogical
(DomNode n, boolean lookLeft) Recursively find the logical node occupying the same position as this _actual_ node.boolean
org.w3c.dom.traversal.NodeFilter
private DomNode
Helper method to get the first uncle node in document order (preorder traversal) from the given node.static int
getFlagForNode
(Node node) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Given aNode
, return the appropriate constant for whatToShow.private DomNode
Helper method to get the previous node in document order (preorder traversal) from the given node.getRoot()
private DomNode
getSibling
(DomNode n, boolean lookLeft) int
private boolean
private boolean
private boolean
Returns whether the node is visible by the TreeWalker.nextNode()
void
setCurrentNode
(Node currentNode)
-
Field Details
-
root_
-
currentNode_
-
whatToShow_
private final int whatToShow_ -
filter_
private final org.w3c.dom.traversal.NodeFilter filter_ -
expandEntityReferences_
private final boolean expandEntityReferences_
-
-
Constructor Details
-
HtmlDomTreeWalker
public HtmlDomTreeWalker(DomNode root, int whatToShow, org.w3c.dom.traversal.NodeFilter filter, boolean expandEntityReferences) throws DOMException Creates an instance.- Parameters:
root
- The root node of the TreeWalker. Must not benull
.whatToShow
- Flag specifying which types of nodes appear in the logical view of the TreeWalker. SeeNodeFilter
for the set of possible Show_ values.filter
- TheNodeFilter
to be used with this TreeWalker, ornull
to indicate no filter.expandEntityReferences
- If false, the contents of EntityReference nodes are not present in the logical view.- Throws:
DOMException
- on attempt to create a TreeWalker with a root that isnull
.
-
-
Method Details
-
getRoot
- Returns:
- the root node
- See Also:
-
getWhatToShow
public int getWhatToShow()- Returns:
- NodeFilter constant
- See Also:
-
getFilter
public org.w3c.dom.traversal.NodeFilter getFilter()- Returns:
- the filter
- See Also:
-
getExpandEntityReferences
public boolean getExpandEntityReferences()- Returns:
- the ExpandEntityReferences setting
- See Also:
-
getCurrentNode
- Returns:
- the current node
- See Also:
-
setCurrentNode
- Parameters:
currentNode
- the current node- Throws:
DOMException
- See Also:
-
nextNode
- Returns:
- the next node
- See Also:
-
getFirstUncleNode
Helper method to get the first uncle node in document order (preorder traversal) from the given node. -
getEquivalentLogical
Recursively find the logical node occupying the same position as this _actual_ node. It could be the same node, a different node, or null depending on filtering.- Parameters:
n
- The actual node we are trying to find the "equivalent" oflookLeft
- If true, traverse the tree in the left direction. If false, traverse the tree to the right.- Returns:
- the logical node in the same position as n
-
isNodeVisible
Returns whether the node is visible by the TreeWalker. -
acceptNode
Test whether a specified node is visible in the logical view of a TreeWalker, based solely on the whatToShow constant.- Parameters:
n
- The node to check to see if it should be shown or not- Returns:
- a constant to determine whether the node is accepted, rejected, or skipped.
-
getFlagForNode
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Given aNode
, return the appropriate constant for whatToShow.- Parameters:
node
- the node- Returns:
- the whatToShow constant for the type of specified node
-
isNodeSkipped
-
isNodeRejected
-
getSibling
-
nextSibling
- Returns:
- the next sibling node
- See Also:
-
parentNode
- Returns:
- the parent node
- See Also:
-
previousSibling
- Returns:
- the previous sibling node
- See Also:
-
lastChild
- Returns:
- the last child node
- See Also:
-
previousNode
- Returns:
- the previous node
- See Also:
-
getPreviousNode
Helper method to get the previous node in document order (preorder traversal) from the given node. -
firstChild
- Returns:
- the first child node
- See Also:
-