org.modeshape.jcr.xpath
Class XPathParser

java.lang.Object
  extended by org.modeshape.jcr.xpath.XPathParser

public class XPathParser
extends Object

A component that parses an XPath query string and creates an abstract syntax tree representation. The supported grammar is defined by JCR 1.0, and is a subset of what is allowed by the W3C XPath 2.0 specification.


Nested Class Summary
static class XPathParser.XPathTokenizer
          A TokenStream.Tokenizer implementation that parses single- and double-quoted strings, symbols, words consisting of NCNames (as defined by the Namespaces in XML 1.0 specification), XPath comments,and other single-character tokens.
 
Constructor Summary
XPathParser(TypeSystem context)
           
 
Method Summary
protected  XPath.Component collapse(XPath.Component component)
           
protected  String decode(String string)
           
protected  XPath.Component parseAdditiveExpr(TokenStream tokens)
           
protected  XPath.Component parseAndExpr(TokenStream tokens)
           
protected  XPath.AnyKindTest parseAnyKindTest(TokenStream tokens)
           
protected  XPath.NameTest parseAtomicType(TokenStream tokens)
           
protected  XPath.AttributeTest parseAttributeTest(TokenStream tokens)
           
protected  XPath.AxisStep parseAxisStep(TokenStream tokens)
           
protected  XPath.Component parseCastableExpr(TokenStream tokens)
           
protected  XPath.Component parseCastExpr(TokenStream tokens)
           
protected  XPath.CommentTest parseCommentTest(TokenStream tokens)
           
protected  XPath.Component parseComparisonExpr(TokenStream tokens)
           
protected  XPath.ContextItem parseContextItemExpr(TokenStream tokens)
           
protected  XPath.DocumentTest parseDocumentTest(TokenStream tokens)
           
protected  XPath.ElementTest parseElementTest(TokenStream tokens)
           
protected  XPath.Component parseExpr(TokenStream tokens)
           
protected  XPath.Component parseExprSingle(TokenStream tokens)
           
protected  XPath.FilterStep parseFilterExpr(TokenStream tokens)
           
protected  XPath.FunctionCall parseFunctionCall(TokenStream tokens)
           
protected  Operator parseGeneralComp(TokenStream tokens)
           
protected  XPath.Component parseInstanceofExpr(TokenStream tokens)
           
protected  XPath.Component parseIntersectExceptExpr(TokenStream tokens)
           
protected  XPath.NameTest parseItemType(TokenStream tokens)
           
protected  XPath.KindTest parseKindTest(TokenStream tokens)
           
protected  XPath.Component parseMultiplicativeExpr(TokenStream tokens)
           
protected  XPath.NameTest parseNameTest(TokenStream tokens)
           
protected  String parseNCName(TokenStream tokens)
           
protected  XPath.NodeComparisonOperator parseNodeComp(TokenStream tokens)
           
protected  XPath.NodeTest parseNodeTest(TokenStream tokens)
           
protected  XPath.Literal parseNumericLiteral(TokenStream tokens)
           
protected  XPath.OrderBy parseOrderBy(TokenStream tokens)
           
protected  XPath.OrderBySpec parseOrderBySpec(TokenStream tokens)
           
protected  XPath.Component parseOrExpr(TokenStream tokens)
           
protected  XPath.ParenthesizedExpression parseParenthesizedExpr(TokenStream tokens)
           
protected  XPath.PathExpression parsePathExpr(TokenStream tokens)
           
protected  XPath.ProcessingInstructionTest parsePITest(TokenStream tokens)
           
protected  List<XPath.Component> parsePredicates(TokenStream tokens)
           
protected  XPath.Component parsePrimaryExpr(TokenStream tokens)
           
protected  XPath.NameTest parseQName(TokenStream tokens)
           
protected  XPath.Component parseRangeExpr(TokenStream tokens)
           
protected  XPath.PathExpression parseRelativePathExpr(TokenStream tokens)
           
protected  XPath.SchemaAttributeTest parseSchemaAttributeTest(TokenStream tokens)
           
protected  XPath.SchemaElementTest parseSchemaElementTest(TokenStream tokens)
           
protected  void parseSequenceType(TokenStream tokens)
           
protected  void parseSingleType(TokenStream tokens)
           
protected  XPath.StepExpression parseStepExpr(TokenStream tokens)
           
protected  XPath.Literal parseStringLiteral(TokenStream tokens)
           
protected  XPath.TextTest parseTextTest(TokenStream tokens)
           
protected  XPath.Component parseTreatExpr(TokenStream tokens)
           
protected  XPath.Component parseUnaryExpr(TokenStream tokens)
           
protected  XPath.Component parseUnionExpr(TokenStream tokens)
           
protected  XPath.Component parseValueComp(TokenStream tokens)
           
protected  XPath.Component parseValueExpr(TokenStream tokens)
           
protected  XPath.NameTest parseWildcard(TokenStream tokens)
           
 XPath.Component parseXPath(String xpath)
           
protected  XPath.Component parseXPath(TokenStream tokens)
           
protected  String removeQuotes(String text)
          Remove any leading and trailing single-quotes or double-quotes from the supplied text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPathParser

public XPathParser(TypeSystem context)
Method Detail

parseXPath

public XPath.Component parseXPath(String xpath)

parseXPath

protected XPath.Component parseXPath(TokenStream tokens)

parseExpr

protected XPath.Component parseExpr(TokenStream tokens)

parseExprSingle

protected XPath.Component parseExprSingle(TokenStream tokens)

parseOrExpr

protected XPath.Component parseOrExpr(TokenStream tokens)

parseAndExpr

protected XPath.Component parseAndExpr(TokenStream tokens)

parseInstanceofExpr

protected XPath.Component parseInstanceofExpr(TokenStream tokens)

parseTreatExpr

protected XPath.Component parseTreatExpr(TokenStream tokens)

parseCastableExpr

protected XPath.Component parseCastableExpr(TokenStream tokens)

parseCastExpr

protected XPath.Component parseCastExpr(TokenStream tokens)

parseComparisonExpr

protected XPath.Component parseComparisonExpr(TokenStream tokens)

parseValueComp

protected XPath.Component parseValueComp(TokenStream tokens)

parseNodeComp

protected XPath.NodeComparisonOperator parseNodeComp(TokenStream tokens)

parseRangeExpr

protected XPath.Component parseRangeExpr(TokenStream tokens)

parseAdditiveExpr

protected XPath.Component parseAdditiveExpr(TokenStream tokens)

parseMultiplicativeExpr

protected XPath.Component parseMultiplicativeExpr(TokenStream tokens)

parseUnaryExpr

protected XPath.Component parseUnaryExpr(TokenStream tokens)

parseUnionExpr

protected XPath.Component parseUnionExpr(TokenStream tokens)

parseIntersectExceptExpr

protected XPath.Component parseIntersectExceptExpr(TokenStream tokens)

parseValueExpr

protected XPath.Component parseValueExpr(TokenStream tokens)

parsePathExpr

protected XPath.PathExpression parsePathExpr(TokenStream tokens)

parseRelativePathExpr

protected XPath.PathExpression parseRelativePathExpr(TokenStream tokens)

parseStepExpr

protected XPath.StepExpression parseStepExpr(TokenStream tokens)

parseAxisStep

protected XPath.AxisStep parseAxisStep(TokenStream tokens)

parsePredicates

protected List<XPath.Component> parsePredicates(TokenStream tokens)

parseFilterExpr

protected XPath.FilterStep parseFilterExpr(TokenStream tokens)

parsePrimaryExpr

protected XPath.Component parsePrimaryExpr(TokenStream tokens)

parseContextItemExpr

protected XPath.ContextItem parseContextItemExpr(TokenStream tokens)

parseParenthesizedExpr

protected XPath.ParenthesizedExpression parseParenthesizedExpr(TokenStream tokens)

parseNumericLiteral

protected XPath.Literal parseNumericLiteral(TokenStream tokens)

parseStringLiteral

protected XPath.Literal parseStringLiteral(TokenStream tokens)

parseFunctionCall

protected XPath.FunctionCall parseFunctionCall(TokenStream tokens)

parseGeneralComp

protected Operator parseGeneralComp(TokenStream tokens)

parseNodeTest

protected XPath.NodeTest parseNodeTest(TokenStream tokens)

parseNameTest

protected XPath.NameTest parseNameTest(TokenStream tokens)

parseQName

protected XPath.NameTest parseQName(TokenStream tokens)

decode

protected String decode(String string)

parseNCName

protected String parseNCName(TokenStream tokens)

parseWildcard

protected XPath.NameTest parseWildcard(TokenStream tokens)

parseItemType

protected XPath.NameTest parseItemType(TokenStream tokens)

parseAtomicType

protected XPath.NameTest parseAtomicType(TokenStream tokens)

parseKindTest

protected XPath.KindTest parseKindTest(TokenStream tokens)

parseAnyKindTest

protected XPath.AnyKindTest parseAnyKindTest(TokenStream tokens)

parsePITest

protected XPath.ProcessingInstructionTest parsePITest(TokenStream tokens)

parseCommentTest

protected XPath.CommentTest parseCommentTest(TokenStream tokens)

parseTextTest

protected XPath.TextTest parseTextTest(TokenStream tokens)

parseDocumentTest

protected XPath.DocumentTest parseDocumentTest(TokenStream tokens)

parseElementTest

protected XPath.ElementTest parseElementTest(TokenStream tokens)

parseSchemaElementTest

protected XPath.SchemaElementTest parseSchemaElementTest(TokenStream tokens)

parseAttributeTest

protected XPath.AttributeTest parseAttributeTest(TokenStream tokens)

parseSchemaAttributeTest

protected XPath.SchemaAttributeTest parseSchemaAttributeTest(TokenStream tokens)

parseSingleType

protected void parseSingleType(TokenStream tokens)

parseSequenceType

protected void parseSequenceType(TokenStream tokens)

parseOrderBy

protected XPath.OrderBy parseOrderBy(TokenStream tokens)

parseOrderBySpec

protected XPath.OrderBySpec parseOrderBySpec(TokenStream tokens)

removeQuotes

protected String removeQuotes(String text)
Remove any leading and trailing single-quotes or double-quotes from the supplied text.

Parameters:
text - the input text; may not be null
Returns:
the text without leading and trailing quotes, or text if there were no square brackets or quotes

collapse

protected XPath.Component collapse(XPath.Component component)


Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.