Class XPathAdapter


  • class XPathAdapter
    extends java.lang.Object
    XPath adapter implementation for HtmlUnit.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  XPathAdapter.STATE  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private org.htmlunit.xpath.compiler.FunctionTable funcTable_  
      private org.htmlunit.xpath.Expression mainExp_  
    • Constructor Summary

      Constructors 
      Constructor Description
      XPathAdapter​(java.lang.String exprString, org.htmlunit.xpath.xml.utils.PrefixResolver prefixResolver, javax.xml.transform.ErrorListener errorListener, boolean caseSensitive)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) org.htmlunit.xpath.objects.XObject execute​(org.htmlunit.xpath.XPathContext xpathContext, int contextNode, org.htmlunit.xpath.xml.utils.PrefixResolver namespaceContext)
      Given an expression and a context, evaluate the XPath and return the result.
      private void initFunctionTable()
      Initiates the function table.
      private static java.lang.String preProcessXPath​(java.lang.String xpath, boolean caseSensitive)
      Pre-processes the specified case-insensitive XPath expression before passing it to the engine.
      • Methods inherited from class java.lang.Object

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

      • mainExp_

        private final org.htmlunit.xpath.Expression mainExp_
      • funcTable_

        private org.htmlunit.xpath.compiler.FunctionTable funcTable_
    • Constructor Detail

      • XPathAdapter

        XPathAdapter​(java.lang.String exprString,
                     org.htmlunit.xpath.xml.utils.PrefixResolver prefixResolver,
                     javax.xml.transform.ErrorListener errorListener,
                     boolean caseSensitive)
              throws javax.xml.transform.TransformerException
        Constructor.
        Parameters:
        exprString - the XPath expression
        prefixResolver - a prefix resolver to use to resolve prefixes to namespace URIs
        errorListener - the error listener, or null if default should be used
        caseSensitive - whether the attributes should be case-sensitive
        Throws:
        javax.xml.transform.TransformerException - if a syntax or other error occurs
    • Method Detail

      • initFunctionTable

        private void initFunctionTable()
        Initiates the function table.
      • preProcessXPath

        private static java.lang.String preProcessXPath​(java.lang.String xpath,
                                                        boolean caseSensitive)
        Pre-processes the specified case-insensitive XPath expression before passing it to the engine. The current implementation lower-cases the attribute name, and anything outside the brackets.
        Parameters:
        xpath - the XPath expression to pre-process
        caseSensitive - whether or not the XPath expression should be case-sensitive
        Returns:
        the processed XPath expression
      • execute

        org.htmlunit.xpath.objects.XObject execute​(org.htmlunit.xpath.XPathContext xpathContext,
                                                   int contextNode,
                                                   org.htmlunit.xpath.xml.utils.PrefixResolver namespaceContext)
                                            throws javax.xml.transform.TransformerException
        Given an expression and a context, evaluate the XPath and return the result.
        Parameters:
        xpathContext - the execution context
        contextNode - the node that "." expresses
        namespaceContext - the context in which namespaces in the XPath are supposed to be expanded
        Returns:
        the result of the XPath or null if callbacks are used
        Throws:
        javax.xml.transform.TransformerException - if the error condition is severe enough to halt processing