Class XPathAdapter

java.lang.Object
org.htmlunit.html.xpath.XPathAdapter

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

    Nested Classes
    Modifier and Type
    Class
    Description
    private static enum 
     
  • Field Summary

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

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

    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
    Initiates the function table.
    private static String
    preProcessXPath(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 Details

    • mainExp_

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

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

    • XPathAdapter

      XPathAdapter(String exprString, org.htmlunit.xpath.xml.utils.PrefixResolver prefixResolver, ErrorListener errorListener, boolean caseSensitive) throws 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:
      TransformerException - if a syntax or other error occurs
  • Method Details

    • initFunctionTable

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

      private static String preProcessXPath(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 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:
      TransformerException - if the error condition is severe enough to halt processing