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

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


      int startPosition = position(expression);
      addProblem(expression, startPosition, RangeVariableDeclaration_MissingRootObject);
    }
    else {

      Expression rootObject = expression.getRootObject();

      if (!isValid(rootObject, RangeDeclarationBNF.ID)) {

        int startPosition = position(rootObject);
        int endPosition   = startPosition + length(rootObject);

        addProblem(expression, startPosition, endPosition, RangeVariableDeclaration_InvalidRootObject);
      }
      else {
        rootObject.accept(this);
      }
    }

    // Missing identification variable
    if (!expression.hasIdentificationVariable() &&
View Full Code Here


    }

    // Invalid trim character
    if (expression.hasTrimCharacter()) {

      Expression trimCharacter = expression.getTrimCharacter();

      // Make sure it's not an input parameter
      String inputParameter = literal(trimCharacter, LiteralType.INPUT_PARAMETER);

      if (ExpressionTools.stringIsEmpty(inputParameter)) {
View Full Code Here

    protected void validateSeparation(CollectionExpression expression) {

      for (int index = 0, count = expression.childrenSize(); index + 1 < count; index++) {

        Expression expression1 = expression.getChild(index);

        if (length(expression1) == 0) {
          int startPosition = position(expression1);
          int endPosition   = startPosition;

          addProblem(
            expression,
            startPosition,
            endPosition,
            CollectionExpression_MissingExpression,
            String.valueOf(index + 1)
          );
        }

        if (!validateSeparator(expression, index)) {
          Expression expression2 = expression.getChild(index + 1);

          int startPosition = position(expression1) + length(expression1);
          int endPosition   = position(expression2);

          // The space is part of the child expression, move backward
          if (!expression.hasSpace(index)) {
            startPosition--;
          }

          if (!validateOnly) {
            addProblem(
              expression,
              startPosition,
              endPosition,
              wrongSeparatorProblemKey,
              expression1.toParsedText(),
              expression2.toParsedText()
            );
          }
        }
      }
    }
View Full Code Here

    protected void validateSeparation(CollectionExpression expression) {

      for (int index = 0, count = expression.childrenSize(); index + 1 < count; index++) {

        Expression expression1 = expression.getChild(index);

        if (length(expression1) == 0) {
          int startPosition = position(expression1);
          int endPosition   = startPosition;

          addProblem(
            expression,
            startPosition,
            endPosition,
            CollectionExpression_MissingExpression,
            String.valueOf(index + 1)
          );
        }

        if (!validateSeparator(expression, index)) {
          Expression expression2 = expression.getChild(index + 1);

          int startPosition = position(expression1) + length(expression1);
          int endPosition   = position(expression2);

          // The space is part of the child expression, move backward
          if (!expression.hasSpace(index)) {
            startPosition--;
          }

          if (!validateOnly) {
            addProblem(
              expression,
              startPosition,
              endPosition,
              wrongSeparatorProblemKey,
              expression1.toParsedText(),
              expression2.toParsedText()
            );
          }
        }
      }
    }
View Full Code Here

      if (position == length) {
        addIdentificationVariables();
        addFunctionIdentifiers(expression.encapsulatedExpressionBNF());
      }
      else if (expression.hasExpression()) {
        Expression scalarExpression = expression.getExpression();

        if (isComplete(scalarExpression)) {
          length += scalarExpression.getLength();

          if (expression.hasSpaceAfterExpression()) {
            length++;

            // Right before "AS" or database type
View Full Code Here

      if (position == length) {
        addIdentificationVariables();
        addFunctionIdentifiers(expression.encapsulatedExpressionBNF());
      }
      else if (expression.hasExpression()) {
        Expression scalarExpression = expression.getExpression();

        if (isComplete(scalarExpression)) {
          length += scalarExpression.getLength();

          if (expression.hasSpaceAfterExpression()) {
            length++;

            // Right before "AS" or database type
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.