Class QLParser
java.lang.Object
org.apache.cayenne.ql.QLParser
- All Implemented Interfaces:
QLParserConstants, QLParserTreeConstants
Parser of Cayenne expressions and queries. Has two entry points:
expression() that parses a standalone
expression, and query() that parses a full select query, whose clauses embed the same expressions.
parse(String, ParseFunction) runs either of them over a String.- Since:
- 5.0 renamed from ExpressionParser and extended to parse queries.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA function run over a fresh parser, seequery()orexpression(). -
Field Summary
FieldsModifier and TypeFieldDescriptionNext token.protected JJTQLParserStateCurrent token.Generated Token Manager.Fields inherited from interface QLParserConstants
ABS, AGGREGATE, ASTERISK, AVG, CONCAT, COUNT, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, DAY, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_YEAR, DEC_DIGITS, DEC_FLT, DEFAULT, DIGIT, DISTINCT, DOLLAR_SIGN, DOUBLE_QUOTED_STRING, EOF, ESC, EXISTS, EXPONENT, FALSE, FLOAT_LITERAL, FLT_SUFF, FUNCTION, HOUR, IDENTIFIER, INT_LITERAL, LENGTH, LETTER, LOCATE, LOWER, MAX, MIN, MINUTE, MOD, MONTH, NOT_EXISTS, NULL, OPERATOR, PROPERTY_PATH, SECOND, SELF, SINGLE_QUOTED_STRING, SQRT, STRING_ESC, SUBSTRING, SUM, tokenImage, TRIM, TRUE, UPPER, WEEK, WithinDoubleQuoteLiteral, WithinSingleQuoteLiteral, YEARFields inherited from interface QLParserTreeConstants
JJTABSEXP, JJTADDEXP, JJTALLEXP, JJTANDEXP, JJTANYEXP, JJTASTERISKEXP, JJTAVGEXP, JJTBETWEENEXP, JJTBITWISEANDEXP, JJTBITWISELEFTSHIFTEXP, JJTBITWISENOTEXP, JJTBITWISEOREXP, JJTBITWISERIGHTSHIFTEXP, JJTBITWISEXOREXP, JJTCONCATEXP, JJTCOUNTEXP, JJTCURRENTDATEEXP, JJTCURRENTTIMEEXP, JJTCURRENTTIMESTAMPEXP, JJTCUSTOMAGGREGATEEXP, JJTCUSTOMFUNCTIONEXP, JJTCUSTOMOPERATOREXP, JJTDBIDPATHEXP, JJTDBPATHEXP, JJTDISTINCTEXP, JJTDIVIDEEXP, JJTENCLOSINGOBJECTEXP, JJTEQUALEXP, JJTEXISTSEXP, JJTEXTRACTEXP, JJTFALSEEXP, JJTFULLOBJECTEXP, JJTGREATEREXP, JJTGREATEROREQUALEXP, JJTINEXP, JJTLENGTHEXP, JJTLESSEXP, JJTLESSOREQUALEXP, JJTLIKEEXP, JJTLIKEIGNORECASEEXP, JJTLISTEXP, JJTLOCATEEXP, JJTLOWEREXP, JJTMAXEXP, JJTMINEXP, JJTMODEXP, JJTMULTIPLYEXP, JJTNEGATEEXP, jjtNodeName, JJTNOTBETWEENEXP, JJTNOTEQUALEXP, JJTNOTEXISTSEXP, JJTNOTEXP, JJTNOTINEXP, JJTNOTLIKEEXP, JJTNOTLIKEIGNORECASEEXP, JJTOBJPATHEXP, JJTOREXP, JJTSQRTEXP, JJTSUBSTRINGEXP, JJTSUBTRACTEXP, JJTSUMEXP, JJTTRIMEXP, JJTTRUEEXP, JJTUPPEREXP, JJTVOID -
Constructor Summary
ConstructorsConstructorDescriptionQLParser(InputStream stream) Constructor with InputStream.QLParser(InputStream stream, String encoding) Constructor with InputStream and supplied encodingConstructor.Constructor with generated Token Manager. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidabs()final voidfinal voidfinal voidfinal voidfinal voidfinal voidasterisk()final voidavg()final voidfinal voidfinal voidfinal voidvoidShould be called when the parsing is finished to ensure all positional values were consumed.final voidcolumn(org.apache.cayenne.ql.QLSelectBuilder builder) final voidfinal voidconcat()final voidfinal voidcount()final voidfinal voidfinal voidfinal voidfinal voidfinal voidfinal voidfinal voidfinal voidDisable tracing.final voiddistinct()final voidEnable tracing.final voidfinal Expressionfinal voidfromClause(org.apache.cayenne.ql.QLSelectBuilder builder) final voidfinal voidGenerate ParseException.final TokenGet the next Token.final TokengetToken(int index) Get the specific Token.final voidfinal voidfinal voidlength()final voidlimitClause(org.apache.cayenne.ql.QLSelectBuilder builder) final voidlocate()final voidlower()final voidmax()final voidmin()final voidmod()final voidfinal Stringname()final voidfinal voidfinal voidfinal voidfinal voidfinal voidfinal voidoffsetClause(org.apache.cayenne.ql.QLSelectBuilder builder) final voidfinal voidorderClause(org.apache.cayenne.ql.QLSelectBuilder builder) final voidordering(org.apache.cayenne.ql.QLSelectBuilder builder) static <T> Tparse(String text, QLParser.ParseFunction<T> function) Build a parser and let the caller decide how to process the result.final voidfinal Tokenfinal voidprefetch(org.apache.cayenne.ql.QLSelectBuilder builder) final voidprefetchClause(org.apache.cayenne.ql.QLSelectBuilder builder) final FluentSelect<?, ?> query()voidReInit(InputStream stream) Reinitialise.voidReInit(InputStream stream, String encoding) Reinitialise.voidReinitialise.voidReinitialise.final voidfinal voidfinal voidfinal FluentSelect<?, ?> select(boolean root) final voidselectClause(org.apache.cayenne.ql.QLSelectBuilder builder) voidsetParameters(Object... parameters) Sets positional values to bind in place of the "$name" tokens, in the order of the first occurrence of the names in the parsed String.voidsetParameters(Map<String, ?> parameters) Sets the values to bind in place of the "$name" tokens by name.final voidfinal voidfinal voidsqrt()final voidfinal voidfinal voidfinal voidsubquery()final voidfinal voidsum()final booleanTrace enabled.final voidtrim()final voidupper()
-
Field Details
-
jjtree
-
token_source
Generated Token Manager. -
token
Current token. -
jj_nt
Next token.
-
-
Constructor Details
-
QLParser
Constructor with InputStream. -
QLParser
Constructor with InputStream and supplied encoding -
QLParser
Constructor. -
QLParser
Constructor with generated Token Manager.
-
-
Method Details
-
parse
Build a parser and let the caller decide how to process the result. Any error is rethrown as anExpressionExceptionwith the original error as its cause.- Since:
- 5.0
-
setParameters
Sets positional values to bind in place of the "$name" tokens, in the order of the first occurrence of the names in the parsed String. A name that occurs more than once consumes a single value. If neither this norsetParameters(Map)is called, the parameters are preserved in the parsed tree. -
setParameters
Sets the values to bind in place of the "$name" tokens by name. Unlike the positional values, a name missing from the map is not an error: the parameter is preserved, and the smallest condition of a "where" or "having" clause that contains it is pruned, in the main query and in the subqueries alike. A null value in the map is bound as is. -
checkParametersBound
public void checkParametersBound()Should be called when the parsing is finished to ensure all positional values were consumed. -
expression
- Throws:
ParseException
-
query
- Throws:
ParseException
-
select
- Throws:
ParseException
-
keyword
- Throws:
ParseException
-
name
- Throws:
ParseException
-
selectClause
- Throws:
ParseException
-
column
- Throws:
ParseException
-
fromClause
- Throws:
ParseException
-
orderClause
- Throws:
ParseException
-
ordering
- Throws:
ParseException
-
limitClause
- Throws:
ParseException
-
offsetClause
- Throws:
ParseException
-
prefetchClause
public final void prefetchClause(org.apache.cayenne.ql.QLSelectBuilder builder) throws ParseException - Throws:
ParseException
-
prefetch
- Throws:
ParseException
-
subquery
- Throws:
ParseException
-
allSubquery
- Throws:
ParseException
-
anySubquery
- Throws:
ParseException
-
comparisonOperand
- Throws:
ParseException
-
inOperand
- Throws:
ParseException
-
orCondition
- Throws:
ParseException
-
andCondition
- Throws:
ParseException
-
notCondition
- Throws:
ParseException
-
simpleCondition
- Throws:
ParseException
-
simpleNotCondition
- Throws:
ParseException
-
scalarCommaList
- Throws:
ParseException
-
conditionExpression
- Throws:
ParseException
-
stringParameter
- Throws:
ParseException
-
stringLiteral
- Throws:
ParseException
-
stringExpression
- Throws:
ParseException
-
scalarExpression
- Throws:
ParseException
-
scalarConstExpression
- Throws:
ParseException
-
numericExpression
- Throws:
ParseException
-
bitwiseOr
- Throws:
ParseException
-
bitwiseXor
- Throws:
ParseException
-
bitwiseAnd
- Throws:
ParseException
-
bitwiseShift
- Throws:
ParseException
-
arithmeticExp
- Throws:
ParseException
-
multiplySubtractExp
- Throws:
ParseException
-
numericTermExt
- Throws:
ParseException
-
numericTerm
- Throws:
ParseException
-
numericPrimary
- Throws:
ParseException
-
enclosing
- Throws:
ParseException
-
functionsReturningStrings
- Throws:
ParseException
-
customFunction
- Throws:
ParseException
-
customOperator
- Throws:
ParseException
-
customAggregate
- Throws:
ParseException
-
concat
- Throws:
ParseException
-
substring
- Throws:
ParseException
-
trim
- Throws:
ParseException
-
lower
- Throws:
ParseException
-
upper
- Throws:
ParseException
-
functionsReturningNumerics
- Throws:
ParseException
-
length
- Throws:
ParseException
-
locate
- Throws:
ParseException
-
abs
- Throws:
ParseException
-
sqrt
- Throws:
ParseException
-
mod
- Throws:
ParseException
-
aggregateExpression
- Throws:
ParseException
-
asterisk
- Throws:
ParseException
-
count
- Throws:
ParseException
-
avg
- Throws:
ParseException
-
max
- Throws:
ParseException
-
min
- Throws:
ParseException
-
sum
- Throws:
ParseException
-
dateTimeFunction
- Throws:
ParseException
-
currentDate
- Throws:
ParseException
-
currentTime
- Throws:
ParseException
-
currentTimestamp
- Throws:
ParseException
-
dateTimeExtractingFunction
- Throws:
ParseException
-
distinct
- Throws:
ParseException
-
namedParameter
- Throws:
ParseException
-
pathExpression
- Throws:
ParseException
-
pathToken
- Throws:
ParseException
-
ReInit
Reinitialise. -
ReInit
Reinitialise. -
ReInit
Reinitialise. -
ReInit
Reinitialise. -
getNextToken
Get the next Token. -
getToken
Get the specific Token. -
generateParseException
Generate ParseException. -
trace_enabled
public final boolean trace_enabled()Trace enabled. -
enable_tracing
public final void enable_tracing()Enable tracing. -
disable_tracing
public final void disable_tracing()Disable tracing.
-