Class JDOQLParser
java.lang.Object
org.datanucleus.store.query.compiler.AbstractParser
org.datanucleus.store.query.compiler.JDOQLParser
- All Implemented Interfaces:
Parser
Implementation of a parser for JDOQL query language.
Generates Node tree(s) by use of the various parseXXX() methods.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate booleanprivate static String[]private static StringCharacters that parameters can be prefixed by.Fields inherited from class AbstractParser
lexer, stack, strict -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidallowSingleEquals(boolean flag) Method to set whether "=" is allowed.private intNode[]Node[]parseOrder(String expression) Node[][]parseParameters(String expression) Node[]parseResult(String expression) The RESULT expression in JDOQL can include aggregates, fields, as well as aliases myfield [AS] alias, myfield2" The Node tree for this would beNode[]parseTuple(String expression) Node[]parseUpdate(String expression) parseVariable(String expression) Node[][]parseVariables(String expression) protected voidprivate voidprivate booleanMethod to parse an array expression ("{a,b,c}"), creating an ARRAY node with the node value being a Listof the elements. private booleanParse any cast expression.private voidThis method deals with the AND condition.private voidThis method deals with the OR condition.private booleanMethod to parse "new a.b.c(param1[,param2], ...)" and create a Node of type CREATOR.private voidprivate Nodeprivate Node[]The FROM expression in JDOQL (subquery) is a "candidate alias" expression, like mydomain.MyClass [AS] alias"private booleanAn identifier always designates a reference to a single value.private voidMethod to parse the query syntax for an "IF ...private voidprotected booleanA literal is one value of any type.private booleanMethod to parse "methodName(param1[,param2], ...)" and create a Node of type INVOKE.protected voidprivate Node[]protected voidParses the primary.private voidParse of an expression that is a relation between expressions.protected voidvoidsetExplicitParameters(boolean flag) Methods inherited from class AbstractParser
getLastDescendantNodeForNode, setStrict
-
Field Details
-
jdoqlMethodNames
-
explicitParams
private boolean explicitParams -
paramPrefixes
Characters that parameters can be prefixed by. -
allowSingleEquals
private boolean allowSingleEquals -
parameterNameList
-
-
Constructor Details
-
JDOQLParser
public JDOQLParser()Constructor for a JDOQL Parser.
-
-
Method Details
-
setExplicitParameters
public void setExplicitParameters(boolean flag) - Specified by:
setExplicitParametersin interfaceParser- Overrides:
setExplicitParametersin classAbstractParser
-
allowSingleEquals
public void allowSingleEquals(boolean flag) Method to set whether "=" is allowed. It is valid in an UPDATE clause, but not in a WHERE clause, for example.- Parameters:
flag- Whether to allow it
-
parse
-
parseVariable
-
parseFrom
-
processFromExpression
The FROM expression in JDOQL (subquery) is a "candidate alias" expression, like- mydomain.MyClass [AS] alias"
- Returns:
- Node tree(s) for the FROM expression
-
parseUpdate
-
parseOrder
-
parseResult
The RESULT expression in JDOQL can include aggregates, fields, as well as aliases- myfield [AS] alias, myfield2"
[ [IDENTIFIER : myfield. [NAME : alias]], [IDENTIFIER : myfield2] ]- Returns:
- Node tree(s) for the RESULT expression
-
parseTuple
-
parseVariables
-
parseParameters
-
processOrderExpression
-
processExpression
-
processConditionalOrExpression
private void processConditionalOrExpression()This method deals with the OR condition. A condition specifies a combination of one or more expressions and logical (Boolean) operators and returns a value of TRUE, FALSE, or unknown -
processConditionalAndExpression
private void processConditionalAndExpression()This method deals with the AND condition. A condition specifies a combination of one or more expressions and logical (Boolean) operators and returns a value of TRUE, FALSE, or unknown -
processInclusiveOrExpression
private void processInclusiveOrExpression() -
processExclusiveOrExpression
private void processExclusiveOrExpression() -
processAndExpression
private void processAndExpression() -
processRelationalExpression
private void processRelationalExpression()Parse of an expression that is a relation between expressions. -
processAdditiveExpression
protected void processAdditiveExpression() -
processMultiplicativeExpression
protected void processMultiplicativeExpression() -
processUnaryExpression
protected void processUnaryExpression() -
processPrimary
protected void processPrimary()Parses the primary. First look for a literal (e.g. "text"), then an identifier(e.g. variable) In the next step, call a function, if executing a function, on the literal or the identifier found. -
processIfElseExpression
private void processIfElseExpression()Method to parse the query syntax for an "IF ... ELSE ..." expression. Creates a Node of type "CASE" with children in the orderifNode, ifActionNode [, ifNode, ifActionNode]*, elseActionNode
-
processCast
private boolean processCast()Parse any cast expression. If a cast is found will create a Node of type CAST with the value being the class to cast to.- Returns:
- Whether a cast was processed
-
processCreator
private boolean processCreator()Method to parse "new a.b.c(param1[,param2], ...)" and create a Node of type CREATOR. The Node at the top of the stack after this call will have any arguments defined in its "properties".- Returns:
- whether method syntax was found.
-
processMethod
private boolean processMethod()Method to parse "methodName(param1[,param2], ...)" and create a Node of type INVOKE. The Node at the top of the stack after this call will have any arguments defined in its "properties".- Returns:
- whether method syntax was found.
-
processArray
private boolean processArray()Method to parse an array expression ("{a,b,c}"), creating an ARRAY node with the node value being a Listof the elements. Also handles processing of subsequent "length" 'method' which is special case for arrays and not caught by processMethod() since it doesn't have "()". - Returns:
- Whether an array was parsed from the current position
-
processLiteral
protected boolean processLiteral()A literal is one value of any type. Supported literals are of types String, Floating Point, Integer, Character, Boolean and null e.g. 'J', "String", 1, 1.8, true, false, null.- Returns:
- The parsed literal
-
processIdentifier
private boolean processIdentifier()An identifier always designates a reference to a single value. A single value can be one collection, one field.- Returns:
- The parsed identifier
-
getPositionFromParameterName
-