Module org.htmlunit

Class HtmlDomTreeWalker

java.lang.Object
org.htmlunit.html.HtmlDomTreeWalker
All Implemented Interfaces:
Serializable

public class HtmlDomTreeWalker extends Object implements Serializable
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.
Author:
Mike Dirolf, Frank Danek, Ahmed Ashour, Ronald Brill
See Also:
  • Constructor Details

    • HtmlDomTreeWalker

      public HtmlDomTreeWalker(DomNode root, int whatToShow, NodeFilter filter, boolean expandEntityReferences) throws DOMException
      Creates an instance.
      Parameters:
      root - The root node of the TreeWalker. Must not be null.
      whatToShow - Flag specifying which types of nodes appear in the logical view of the TreeWalker. See NodeFilter for the set of possible Show_ values.
      filter - The NodeFilter to be used with this TreeWalker, or null 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 is null.
  • Method Details

    • getRoot

      public DomNode getRoot()
      Returns the root node of this tree walker.
      Returns:
      the root node
      See Also:
    • getWhatToShow

      public int getWhatToShow()
      Returns the node types visible to this tree walker.
      Returns:
      NodeFilter constant
      See Also:
    • getFilter

      public NodeFilter getFilter()
      Returns the node filter used by this tree walker.
      Returns:
      the filter
      See Also:
    • getExpandEntityReferences

      public boolean getExpandEntityReferences()
      Returns whether entity reference nodes are expanded.
      Returns:
      the ExpandEntityReferences setting
      See Also:
    • getCurrentNode

      public DomNode getCurrentNode()
      Returns the current node.
      Returns:
      the current node
      See Also:
    • setCurrentNode

      public void setCurrentNode(Node currentNode) throws DOMException
      Sets the current node.
      Parameters:
      currentNode - the current node
      Throws:
      DOMException - if the current node provided is null
      See Also:
    • nextNode

      public DomNode nextNode()
      Returns the next node in document order.
      Returns:
      the next node
      See Also:
    • getFlagForNode

      public static int getFlagForNode(Node node)
      INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
      Given a Node, return the appropriate constant for whatToShow.
      Parameters:
      node - the node
      Returns:
      the whatToShow constant for the type of specified node
    • nextSibling

      public DomNode nextSibling()
      Returns the next sibling of the current node.
      Returns:
      the next sibling node
      See Also:
    • parentNode

      public DomNode parentNode()
      Returns the parent of the current node.
      Returns:
      the parent node
      See Also:
    • previousSibling

      public DomNode previousSibling()
      Returns the previous sibling of the current node.
      Returns:
      the previous sibling node
      See Also:
    • lastChild

      public DomNode lastChild()
      Returns the last child of the current node.
      Returns:
      the last child node
      See Also:
    • previousNode

      public DomNode previousNode()
      Returns the previous node in document order.
      Returns:
      the previous node
      See Also:
    • firstChild

      public DomNode firstChild()
      Returns the first child of the current node.
      Returns:
      the first child node
      See Also: