Class QueryParser
- java.lang.Object
-
- org.apache.jackrabbit.spi.commons.query.QueryParser
-
public class QueryParser extends java.lang.Object
This class acts as the central entry point for parsing query statements from different query syntaxes into a query tree.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static QueryRootNode
parse(java.lang.String statement, java.lang.String language, NameResolver resolver, QueryNodeFactory factory)
Parses a querystatement
according to a querylanguage
into a query tree.static java.lang.String
toString(QueryRootNode root, java.lang.String language, NameResolver resolver)
Creates a String representation of the QueryNode tree argumentroot
.
-
-
-
Method Detail
-
parse
public static QueryRootNode parse(java.lang.String statement, java.lang.String language, NameResolver resolver, QueryNodeFactory factory) throws InvalidQueryException
Parses a querystatement
according to a querylanguage
into a query tree.language
must be one of:Query.SQL
,Query.XPATH
.- Parameters:
statement
- the query statement.language
- the language of the query statement.factory
- the query node factory.- Returns:
- the root node of the generated query tree.
- Throws:
InvalidQueryException
- if an error occurs while parsing the statement.
-
toString
public static java.lang.String toString(QueryRootNode root, java.lang.String language, NameResolver resolver) throws InvalidQueryException
Creates a String representation of the QueryNode tree argumentroot
. The argumentlanguage
specifies the syntax. See also:QueryManager.getSupportedQueryLanguages()
.- Parameters:
root
- the query node tree.language
- one of the languages returned by:QueryManager.getSupportedQueryLanguages()
.resolver
- to resolve QNames.- Returns:
- a String representation of the query node tree.
- Throws:
InvalidQueryException
- if the query node tree cannot be converted into a String representation of the given language. This might be due to syntax restrictions of the given language. This exception is also thrown iflanguage
is not one of the supported query languages returned by theQueryManager
.
-
-