Class JDOQLParser

java.lang.Object
org.datanucleus.store.query.compiler.AbstractParser
org.datanucleus.store.query.compiler.JDOQLParser
All Implemented Interfaces:
Parser

public class JDOQLParser extends AbstractParser
Implementation of a parser for JDOQL query language. Generates Node tree(s) by use of the various parseXXX() methods.
  • Field Details

    • jdoqlMethodNames

      private static String[] jdoqlMethodNames
    • explicitParams

      private boolean explicitParams
    • paramPrefixes

      private static String paramPrefixes
      Characters that parameters can be prefixed by.
    • allowSingleEquals

      private boolean allowSingleEquals
    • parameterNameList

      private List<Object> parameterNameList
  • Constructor Details

    • JDOQLParser

      public JDOQLParser()
      Constructor for a JDOQL Parser.
  • Method Details

    • setExplicitParameters

      public void setExplicitParameters(boolean flag)
      Specified by:
      setExplicitParameters in interface Parser
      Overrides:
      setExplicitParameters in class AbstractParser
    • 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

      public Node parse(String expression)
    • parseVariable

      public Node parseVariable(String expression)
    • parseFrom

      public Node[] parseFrom(String expression)
    • processFromExpression

      private Node[] 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

      public Node[] parseUpdate(String expression)
    • parseOrder

      public Node[] parseOrder(String expression)
    • parseResult

      public 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 be
      [
       [IDENTIFIER : myfield.
            [NAME : alias]],
       [IDENTIFIER : myfield2]
       ]
      Returns:
      Node tree(s) for the RESULT expression
    • parseTuple

      public Node[] parseTuple(String expression)
    • parseVariables

      public Node[][] parseVariables(String expression)
    • parseParameters

      public Node[][] parseParameters(String expression)
    • processOrderExpression

      private Node[] processOrderExpression()
    • processExpression

      private Node 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 order
      ifNode, 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 List of 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

      private int getPositionFromParameterName(Object name)