Class QuickXPathParser

  • All Implemented Interfaces:
    XPathParser.Accelerator

    public class QuickXPathParser
    extends java.lang.Object
    implements XPathParser.Accelerator
    This class performs a quick parse of commonly encountered XPath expressions that conform to common syntactic patterns. Instead of using the full recursive-descent parser, the expression is tokenized, and the sequence of tokens is tested against a table of known common sequences. If the XPath expression supplied cannot be parsed (either because it is too complicated or because it is invalid), the quick parser simply returns null and leaves the work to the regular parser.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Expression parse​(Tokenizer t, StaticContext env, java.lang.String expression, int start, int terminator)
      Attempt to parse an expression, provided it is very simple.
      • Methods inherited from class java.lang.Object

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

      • QuickXPathParser

        public QuickXPathParser()
    • Method Detail

      • parse

        public Expression parse​(Tokenizer t,
                                StaticContext env,
                                java.lang.String expression,
                                int start,
                                int terminator)
        Attempt to parse an expression, provided it is very simple.
        Specified by:
        parse in interface XPathParser.Accelerator
        Parameters:
        t - the tokenizer
        expression - the string containing expression to be parsed
        start - start position within the input string
        terminator - either EOF or RCURLY, indicating how parsing should end
        env - the static context
        Returns:
        either the parsed expression, or null if it is erroneous or too complex to parse.