Class NodeSelector


  • public class NodeSelector
    extends java.lang.Object
    Node selector selects DOM nodes using CSS3 selectors. Group of queries are supported.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Node rootNode  
    • Constructor Summary

      Constructors 
      Constructor Description
      NodeSelector​(Node rootNode)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean filter​(java.util.List<Node> currentResults, Node node, CssSelector cssSelector, int index)
      Filter nodes.
      protected void processSelectors​(java.util.List<Node> results, java.util.List<CssSelector> selectors)
      Process selectors and keep adding results.
      java.util.List<Node> select​(java.lang.String query)
      Selects nodes using CSS3 selector query.
      java.util.List<Node> select​(java.util.Collection<java.util.List<CssSelector>> selectorsCollection)
      Selected nodes using pre-parsed CSS selectors.
      java.util.List<Node> select​(NodeFilter nodeFilter)
      Selects nodes using node filter.
      protected java.util.List<Node> select​(Node rootNode, java.util.List<CssSelector> selectors)  
      protected void selectAndAdd​(Node node, CssSelector cssSelector, java.util.List<Node> result)
      Selects single node for single selector and appends it to the results.
      Node selectFirst​(java.lang.String query)
      Selects nodes using CSS3 selector query and returns the very first one.
      Node selectFirst​(NodeFilter nodeFilter)
      Selects nodes using node filter and return the very first one.
      protected void walk​(Node rootNode, CssSelector cssSelector, java.util.List<Node> result)
      Finds nodes in the tree that matches single selector.
      protected void walk​(Node rootNode, NodeFilter nodeFilter, java.util.List<Node> result)  
      protected void walkDescendantsIteratively​(java.util.LinkedList<Node> nodes, CssSelector cssSelector, java.util.List<Node> result)
      Walks over the child notes, maintaining the tree order and not using recursion.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • rootNode

        protected final Node rootNode
    • Constructor Detail

      • NodeSelector

        public NodeSelector​(Node rootNode)
    • Method Detail

      • select

        public java.util.List<Node> select​(java.lang.String query)
        Selects nodes using CSS3 selector query.
      • select

        public java.util.List<Node> select​(java.util.Collection<java.util.List<CssSelector>> selectorsCollection)
        Selected nodes using pre-parsed CSS selectors. Take in consideration collection type for results grouping order.
      • processSelectors

        protected void processSelectors​(java.util.List<Node> results,
                                        java.util.List<CssSelector> selectors)
        Process selectors and keep adding results.
      • selectFirst

        public Node selectFirst​(java.lang.String query)
        Selects nodes using CSS3 selector query and returns the very first one.
      • selectFirst

        public Node selectFirst​(NodeFilter nodeFilter)
        Selects nodes using node filter and return the very first one.
      • walk

        protected void walk​(Node rootNode,
                            NodeFilter nodeFilter,
                            java.util.List<Node> result)
      • select

        protected java.util.List<Node> select​(Node rootNode,
                                              java.util.List<CssSelector> selectors)
      • walkDescendantsIteratively

        protected void walkDescendantsIteratively​(java.util.LinkedList<Node> nodes,
                                                  CssSelector cssSelector,
                                                  java.util.List<Node> result)
        Walks over the child notes, maintaining the tree order and not using recursion.
      • walk

        protected void walk​(Node rootNode,
                            CssSelector cssSelector,
                            java.util.List<Node> result)
        Finds nodes in the tree that matches single selector.
      • selectAndAdd

        protected void selectAndAdd​(Node node,
                                    CssSelector cssSelector,
                                    java.util.List<Node> result)
        Selects single node for single selector and appends it to the results.
      • filter

        protected boolean filter​(java.util.List<Node> currentResults,
                                 Node node,
                                 CssSelector cssSelector,
                                 int index)
        Filter nodes.