Package org.eclipse.persistence.jpa.jpql.parser

Examples of org.eclipse.persistence.jpa.jpql.parser.Expression


      // The only thing that is appendable is an arithmetic operator
      // Example: "SELECT e FROM Employee e WHERE e.name|"
      // Example: "SELECT e FROM Employee e WHERE I|"
      if ((index == 0) && !virtualSpace) {

        Expression child = collectionExpression.getChild(0);

        if (areArithmeticSymbolsAppendable(child)) {
          addArithmeticIdentifiers();
        }
      }
      else {

        Object[] result = findChild(collectionExpression, index);

        if (result == null) {
          return;
        }

        Expression child = (Expression) result[0];
        boolean hasIs  = (Boolean) result[1];
        boolean hasNot = (Boolean) result[2];

        // If 'IS' or 'IS NOT' is present, then none of the following are valid proposals
        if (!hasIs && !hasNot) {
View Full Code Here


     */
    public boolean canContinue(AbstractConditionalClause expression,
                               CollectionExpression collectionExpression,
                               int index) {

      Expression child = collectionExpression.getChild(index);

      if (isNotExpression(child)) {
        return true;
      }

      String text = child.toParsedText();

      return text.equalsIgnoreCase(IS||
             text.equalsIgnoreCase(NOT) ||
             text.equalsIgnoreCase("IS NOT");
    }
View Full Code Here

      boolean isFound = false;
      boolean scanPrevious = false;

      for (; index > -1; index--) {

        Expression child = collectionExpression.getChild(index);
        String text = child.toParsedText();

        // Handle 'NOT'
        if (text.equalsIgnoreCase(NOT) || isNotExpression(child)) {

          // Two consecutive 'NOT' or 'IS' is invalid or 'NOT IS' is not valid
View Full Code Here

      }
      else {

        // Special case if what's before is 'IS' or 'IS NOT', then it's not appendable
        if (positionInCollection > 1) {
          Expression child = collectionExpression.getChild(positionInCollection - 1);
          String text = child.toActualText();
          appendable = !text.equals(IS) && !text.equals("IS NOT");
        }
        else {
          switch (appendableType) {
            case ARITHMETIC:
View Full Code Here

      }
      else {

        // Special case if what's before is 'IS' or 'IS NOT', then it's not appendable
        if (positionInCollection > 1) {
          Expression child = collectionExpression.getChild(positionInCollection - 1);
          String text = child.toActualText();
          appendable = !text.equals(IS) && !text.equals("IS NOT");
        }
        else {
          switch (appendableType) {
            case ARITHMETIC:
View Full Code Here

   * {@inheritDoc}
   */
  @Override
  protected void validateRangeVariableDeclarationRootObject(RangeVariableDeclaration expression) {

    Expression rootObject = expression.getRootObject();

    // Special case, the path expression could be a fully qualified class name,
    // make sure to not validate it as collection-valued path expression
    CollectionValuedPathExpression pathExpression = getCollectionValuedPathExpression(rootObject);

    if (pathExpression != null) {
      String path = pathExpression.toActualText();

      // The path expression is not a fully qualified class name
      if (helper.getType(path) == null) {
        pathExpression.accept(this);
      }
    }
    else {
      rootObject.accept(this);
    }
  }
View Full Code Here

      @Override
      @SuppressWarnings("fallthrough")
      protected String encapsulatedExpressionInvalidKey(FunctionExpression expression) {
        switch (expression.getParameterCount()) {
          case ONE: {
            Expression children = expression.getExpression();
            int childrenCount = getChildren(children).size();
            if (childrenCount > 1) {
              return FunctionExpression_MoreThanOneExpression;
            }
          }
          case ZERO: {
            return FunctionExpression_HasExpression;
          }
          default: {
            return FunctionExpression_InvalidExpression;
          }
        }
      }
      @Override
      @SuppressWarnings("fallthrough")
      protected String encapsulatedExpressionMissingKey(FunctionExpression expression) {
        switch (expression.getParameterCount()) {
          case ONE: {
            Expression children = expression.getExpression();
            int childrenCount = getChildren(children).size();
            if (childrenCount == 0) {
              return FunctionExpression_MissingOneExpression;
            }
          }
View Full Code Here

                          (expression.hasSpaceAfterIdentifier() ? 1 : 0);

      addProblem(expression, startPosition, endPosition, missingConditionalExpressionMessageKey);
    }
    else {
      Expression conditionalExpression = expression.getConditionalExpression();

      // Invalid conditional expression
      // Example: "... WHERE foo() = 1", right now it's parsed as 3 expressions
      if (getChildren(conditionalExpression).size() > 1) {
        int startPosition = position(conditionalExpression);
        int endPosition   = startPosition + length(conditionalExpression);
        addProblem(expression, startPosition, endPosition, invalidConditionalExpressionMessageKey);
      }
      else {
        // Invalid conditional expression
        if (!isValid(conditionalExpression, ConditionalExpressionBNF.ID)) {
          int startPosition = position(conditionalExpression);
          int endPosition   = startPosition + length(conditionalExpression);
          addProblem(expression, startPosition, endPosition, invalidConditionalExpressionMessageKey);
        }

        // Visit the conditional expression
        conditionalExpression.accept(this);
      }
    }
  }
View Full Code Here

                          (expression.hasSpaceAfterFrom() ? 1 : 0);

      addProblem(expression, startPosition, AbstractFromClause_MissingIdentificationVariableDeclaration);
    }
    else {
      Expression declaration = expression.getDeclaration();

      // Two identification variable declarations have to be separated by a comma and
      // the FROM clause cannot end with a comma
      validateCollectionSeparatedByComma(
        declaration,
        AbstractFromClause_IdentificationVariableDeclarationEndsWithComma,
        AbstractFromClause_IdentificationVariableDeclarationIsMissingComma
      );

      // Validate the declaration
      declaration.accept(this);
    }
  }
View Full Code Here

                          (expression.hasSpaceAfterDistinct() ? 1 : 0);

      addProblem(expression, startPosition, AbstractSelectClause_MissingSelectExpression);
    }
    else {
      Expression selectExpression = expression.getSelectExpression();

      // Check for collection expression first
      if (isCollectionExpression(selectExpression)) {

        // The SELECT clause does not support a collection of select expressions
        if (!multipleSelectItemsAllowed) {

          int startPosition = position(expression) +
                              6 /* SELECT */ +
                              (expression.hasSpaceAfterSelect() ? 1 : 0) +
                              (expression.hasDistinct() ? 8 : 0) +
                              (expression.hasSpaceAfterDistinct() ? 1 : 0);

          int endPosition = startPosition + length(selectExpression);

          addProblem(selectExpression, startPosition, endPosition, SimpleSelectClause_NotSingleExpression);
        }
        // Visit the select expression
        else {
          selectExpression.accept(this);
        }
      }
      // The select expression is not valid
      else if (!isValid(selectExpression, expression.selectItemBNF())) {

        int startPosition = position(expression) +
                            6 /* SELECT */ +
                            (expression.hasSpaceAfterSelect() ? 1 : 0) +
                            (expression.hasDistinct() ? 8 : 0) +
                            (expression.hasSpaceAfterDistinct() ? 1 : 0);

        int endPosition = startPosition + length(selectExpression);

        addProblem(expression, startPosition, endPosition, AbstractSelectClause_InvalidSelectExpression);
      }
      // Visit the select expression
      else {
        selectExpression.accept(this);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.jpa.jpql.parser.Expression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.