jd.xml.xpath.parser
Class ExpressionParser

java.lang.Object
  extended byjd.xml.xpath.parser.ExpressionParser
All Implemented Interfaces:
TokenConstants
Direct Known Subclasses:
PatternParser

public class ExpressionParser
extends Object
implements TokenConstants

An XPath expression parser.


Field Summary
 
Fields inherited from interface jd.xml.xpath.parser.TokenConstants
AT, AXISNAME, BRACKET_CLOSE, BRACKET_OPEN, COMMA, DOT, DOTDOT, END_OF_EXPRESSION, EQUALS, GREATER, GREATER_EQUALS, LESS, LESS_EQUALS, LITERAL, MAX, MINUS, MULTIPLY, NAME, NOT_EQUALS, NUMBER, PARENTHESIS_CLOSE, PARENTHESIS_OPEN, PLUS, SLASH, SLASHSLASH, UNDEFINED, UNION, VARIABLE_REFERENCE
 
Constructor Summary
ExpressionParser()
          Create an ExpressionParser using the default XPath function library
ExpressionParser(XPathParseContext context)
          Create a ExpressionParser using the given FunctionLibrary.
 
Method Summary
protected  Expression createFunction(Scanner scanner, String functionName, Expression[] arguments)
          Create a function call expression for a function with the given name and arguments.
protected  String getNamespaceUri(Scanner scanner, String prefix)
          Return the namespace uri for the given prefix.
 Expression parseExpression(Scanner scanner)
          Parse the production rule: Expr ::= OrExpr
 Expression parseExpression(String expression)
           
 NodeNameTest parseNodeNameTest(Scanner scanner, String qname, boolean useNamePool)
           
protected  NodeTest parseNodeTest(Scanner scanner)
           
protected  NodeTest parseNodeTest(Scanner scanner, String name)
           
 NodeTest parseNodeTest(String nodeTestString)
           
protected  VariableReference parseVariableReference(Scanner scanner)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionParser

public ExpressionParser()
Create an ExpressionParser using the default XPath function library


ExpressionParser

public ExpressionParser(XPathParseContext context)
Create a ExpressionParser using the given FunctionLibrary.

Method Detail

parseExpression

public Expression parseExpression(String expression)
                           throws XPathParseException
Throws:
XPathParseException

parseExpression

public Expression parseExpression(Scanner scanner)
                           throws XPathParseException
Parse the production rule: Expr ::= OrExpr

Throws:
XPathParseException

parseVariableReference

protected VariableReference parseVariableReference(Scanner scanner)
                                            throws XPathParseException
Throws:
XPathParseException

createFunction

protected Expression createFunction(Scanner scanner,
                                    String functionName,
                                    Expression[] arguments)
                             throws XPathParseException
Create a function call expression for a function with the given name and arguments. Since xpath can be enhanced by adding more functions to the default function library this factory method gives derived parser the ability to influence the creation of the function when needed. The default implementation returns a simple FunctionCall object

Throws:
XPathParseException

parseNodeTest

public NodeTest parseNodeTest(String nodeTestString)
                       throws XPathParseException
Throws:
XPathParseException

parseNodeTest

protected NodeTest parseNodeTest(Scanner scanner)
                          throws XPathParseException
Throws:
XPathParseException

parseNodeTest

protected NodeTest parseNodeTest(Scanner scanner,
                                 String name)
                          throws XPathParseException
Throws:
XPathParseException

parseNodeNameTest

public NodeNameTest parseNodeNameTest(Scanner scanner,
                                      String qname,
                                      boolean useNamePool)
                               throws XPathParseException
Throws:
XPathParseException

getNamespaceUri

protected String getNamespaceUri(Scanner scanner,
                                 String prefix)
                          throws XPathParseException
Return the namespace uri for the given prefix. The default implementation throws an XPathException

Throws:
XPathParseException