Class AstNodeXPathQuery<T>


  • public final class AstNodeXPathQuery<T>
    extends Object
    • Method Detail

      • selectSingleNode

        public T selectSingleNode​(AstNode astNode)
        Evaluate the XPath query on the given AstNode and returns the first result, or null if there was no result.
         In the following case, AstNodeXpathQuery.create('/a/b').selectSingleNode(node) would return the AstNode of B2.
        
           A1
            |__ C1
            |    |__ B1
            |__ B2
            |__ B3
         
        Parameters:
        astNode - The AstNode on which to evaluate the query against to.
        Returns:
        The first result or null if there was no result.
      • selectNodes

        public List<T> selectNodes​(AstNode astNode)
        Evaluate the XPath query on the given AstNode and returns all matching elements.
         In the following case, AstNodeXpathQuery.create('/a/b').selectNodes(node) would return the AstNode of B2 and B3, in that order.
        
           A1
            |__ C1
            |    |__ B1
            |__ B2
            |__ B3
         
        Parameters:
        astNode - The AstNode on which to evaluate the query against to.
        Returns:
        The list of resulting elements, empty when no result available.
      • create

        public static <E> AstNodeXPathQuery<E> create​(String xpath)
        Creates a compiled XPath query, which can be evaluated multiple times on different AstNode.
        Parameters:
        xpath - The query to compile
        Returns:
        The compiled XPath query