org.overlord.sramp.common.query.xpath
Class XPathParser

java.lang.Object
  extended by org.overlord.sramp.common.query.xpath.XPathParser

public class XPathParser
extends Object

Parses an XPath query string and creates an abstract syntax tree representation. The supported grammar is defined by the S-RAMP specification and is a subset of the XPath 2.0 grammar.


Constructor Summary
XPathParser()
          Default constructor.
 
Method Summary
 String getDefaultPrefix()
           
 NamespaceContext getNamespaceContext()
           
protected  Query parseQuery(TokenStream tokens)
          Parses a Query from the given token stream.
 Query parseXPath(String xpath)
          Called to parse the XPath query into an S-RAMP XPath AST.
protected  String removeQuotes(String text)
          Remove any leading and trailing single-quotes or double-quotes from the supplied text.
 void setDefaultPrefix(String defaultPrefix)
           
 void setNamespaceContext(NamespaceContext namespaceContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPathParser

public XPathParser()
Default constructor.

Method Detail

getNamespaceContext

public NamespaceContext getNamespaceContext()
Returns:
the namespaceContext

setNamespaceContext

public void setNamespaceContext(NamespaceContext namespaceContext)
Parameters:
namespaceContext - the namespaceContext to set

getDefaultPrefix

public String getDefaultPrefix()
Returns:
the defaultPrefix

setDefaultPrefix

public void setDefaultPrefix(String defaultPrefix)
Parameters:
defaultPrefix - the defaultPrefix to set

parseXPath

public Query parseXPath(String xpath)
Called to parse the XPath query into an S-RAMP XPath AST.

Parameters:
xpath - the S-RAMP Query being parsed
Returns:
an S-RAMP XPath AST

parseQuery

protected Query parseQuery(TokenStream tokens)
Parses a Query from the given token stream.

Parameters:
tokens - the X-Path token stream
Returns:
a Query

removeQuotes

protected String removeQuotes(String text)
Remove any leading and trailing single-quotes or double-quotes from the supplied text. Also unescape any possibly escaped quote characters. The result of calling this method will be the real value of a quoted string from the query.

Parameters:
text - the input text
Returns:
the text without leading and trailing quotes


Copyright © 2011-2013 JBoss, a division of Red Hat. All Rights Reserved.