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

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


    if (!expression.hasLeftExpression()) {
      int startPosition = position(expression);
      addProblem(expression, startPosition, missingLeftExpression);
    }
    else {
      Expression leftExpression = expression.getLeftExpression();

      // Invalid left expression
      if (!isValid(leftExpression, leftExpressionQueryBNF)) {

        int startPosition = position(expression);
        int endPosition   = startPosition + length(leftExpression);
        addProblem(expression, startPosition, endPosition, invalidLeftExpression);
      }
      else {
        leftExpression.accept(this);
      }
    }

    // Missing right expression
    if (!expression.hasRightExpression()) {

      int startPosition = position(expression) +
                          length(expression.getLeftExpression()) +
                          (expression.hasLeftExpression() ? 1 : 0) +
                          identifier.length() +
                          (expression.hasSpaceAfterIdentifier() ? 1 : 0);

      addProblem(expression, startPosition, missingRightExpression);
    }
    else {
      Expression rightExpression = expression.getRightExpression();

      // Invalid right expression
      if (!isValid(rightExpression, rightExpressionQueryBNF)) {

        int startPosition = position(expression) +
                            length(expression.getLeftExpression()) +
                            (expression.hasLeftExpression() ? 1 : 0) +
                            identifier.length() +
                            (expression.hasSpaceAfterIdentifier() ? 1 : 0);

        int endPosition = startPosition + length(rightExpression);

        addProblem(expression, startPosition, endPosition, invalidRightExpression);
      }
      else {
        rightExpression.accept(this);
      }
    }
  }
View Full Code Here


  protected void validateJoins(IdentificationVariableDeclaration expression) {

    // Validate the JOIN expressions
    if (expression.hasJoins()) {

      Expression joins = expression.getJoins();
      List<Expression> children = getChildren(joins);

      // Validate multiple JOIN expression
      if (children.size() > 1) {

        validateCollectionSeparatedBySpace(
          joins,
          IdentificationVariableDeclaration_JoinsEndWithComma,
          IdentificationVariableDeclaration_JoinsHaveComma
        );

        // Make sure each child is a JOIN expression
        for (int index = children.size(); --index >= 0; ) {
          Expression child = children.get(index);
          child.accept(this);
        }
      }
      // Make sure the single expression is a JOIN expression
      // Validate the JOIN expression
      else {
View Full Code Here

    }
  }

  protected void validateLikeExpressionEscapeCharacter(LikeExpression expression) {

    Expression escapeCharacter = expression.getEscapeCharacter();

    // Check for a string literal (single quoted character)
    String character = literal(escapeCharacter, LiteralType.STRING_LITERAL);

    // Check for a single character
    if ((character.length() > 0) && ExpressionTools.isQuote(character.charAt(0))) {

      // Unquote the literal first
      character = ExpressionTools.unquote(character);

      // The escape character is not a single character literal
      if (character.length() != 1) {

        int startPosition = position(expression) +
                            length(expression.getStringExpression()) +
                            (expression.hasSpaceAfterStringExpression() ? 1 : 0) +
                            (expression.hasNot() ? 4 : 0) +
                            4 /* LIKE */ +
                            (expression.hasSpaceAfterLike() ? 1 : 0) +
                            length(expression.getPatternValue()) +
                            (expression.hasSpaceAfterPatternValue() ? 1 : 0) +
                            6 + /* ESCAPE */ +
                            (expression.hasSpaceAfterEscape() ? 1 : 0);

        int endPosition = startPosition +  length(escapeCharacter);

        addProblem(
          expression,
          startPosition,
          endPosition,
          LikeExpression_InvalidEscapeCharacter,
          escapeCharacter.toActualText()
        );
      }
    }
    else {
      // Check for an input parameter
      character = literal(escapeCharacter, LiteralType.INPUT_PARAMETER);

      if ((character.length() == 0) &&
          !isValid(escapeCharacter, LikeExpressionEscapeCharacterBNF.ID)) {

        int startPosition = position(expression) +
                            length(expression.getStringExpression()) +
                            4 /* LIKE */ +
                            (expression.hasSpaceAfterStringExpression() ? 1 : 0) +
                            (expression.hasNot() ? 1 : 0) +
                            (expression.hasSpaceAfterLike() ? 1 : 0) +
                            length(expression.getPatternValue()) +
                            (expression.hasSpaceAfterPatternValue() ? 1 : 0) +
                            6 + /* ESCAPE */ +
                            (expression.hasSpaceAfterEscape() ? 1 : 0);

        int endPosition = startPosition + length(escapeCharacter);

        addProblem(
          expression,
          startPosition,
          endPosition,
          LikeExpression_InvalidEscapeCharacter,
          escapeCharacter.toActualText()
        );
      }
    }
  }
View Full Code Here

    if (!expression.hasExpression()) {
      int startPosition = position(expression) + 1;
      addProblem(expression, startPosition, ArithmeticFactor_MissingExpression);
    }
    else {
      Expression arithmeticExpression = expression.getExpression();

      if (!isValid(arithmeticExpression, ArithmeticPrimaryBNF.ID)) {
        int startIndex = position(expression) + 1;
        int endIndex   = startIndex;
        addProblem(expression, startIndex, endIndex, ArithmeticFactor_InvalidExpression);
      }
      else {
        arithmeticExpression.accept(this);
      }
    }
  }
View Full Code Here

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

      addProblem(expression, startPosition, CollectionMemberExpression_MissingCollectionValuedPathExpression);
    }
    else {
      Expression pathExpression = expression.getCollectionValuedPathExpression();

      // The expression is not a path expression
      if (!isValid(pathExpression, CollectionValuedPathExpressionBNF.ID)) {

        int startPosition = position(expression) +
View Full Code Here

      // More than one entity abstract schema type is declared
      CollectionExpression collectionExpression = getCollectionExpression(expression.getRangeVariableDeclaration());

      if (collectionExpression != null) {
        Expression firstChild = collectionExpression.getChild(0);
        int startPosition = position(firstChild) + length(firstChild);
        int endPosition = position(collectionExpression) + length(collectionExpression);
        boolean malformed = false;

        for (int index = collectionExpression.childrenSize() - 1; --index >= 0; ) {
View Full Code Here

    if (!expression.hasExpression()) {
      int startPosition = position(expression);
      addProblem(expression, startPosition, EmptyCollectionComparisonExpression_MissingExpression);
    }
    else {
      Expression pathExpression = expression.getExpression();

      // The expression is not a path expression
      if (!isValid(pathExpression, CollectionValuedPathExpressionBNF.ID)) {

        int startPosition = position(expression);
View Full Code Here

    if (!expression.hasExpression()) {
      int startPosition = position(expression);
      addProblem(expression, startPosition, InExpression_MissingExpression);
    }
    else {
      Expression leftExpression = expression.getExpression();

      if (!isValid(leftExpression, expression.getExpressionExpressionBNF()) ||
          isDateTimeConstant(leftExpression)) {

        int startPosition = position(expression);
        int endPosition   = startPosition + length(leftExpression);
        addProblem(expression, startPosition, endPosition, InExpression_InvalidExpression);
      }
      else {
        leftExpression.accept(this);
      }
    }

    // Check for "IN :input_parameter" defined in JPA 2.0
    boolean singleInputParameter = isNewerThanOrEqual(JPAVersion.VERSION_2_0) &&
View Full Code Here

        joinFetch ? JoinFetch_MissingJoinAssociationPath : Join_MissingJoinAssociationPath
      );
    }
    else {

      Expression joinAssociationPath = expression.getJoinAssociationPath();

      // Invalid join association path
      if (!isValid(joinAssociationPath, JoinAssociationPathExpressionBNF.ID)) {

        int startPosition = position(joinAssociationPath);
        int endPosition   = startPosition + length(joinAssociationPath);
        addProblem(expression, startPosition, endPosition, Join_InvalidJoinAssociationPath);
      }
      // Validate join association path
      else {
        joinAssociationPath.accept(this);
      }
    }

    // Missing identification variable
    // A JOIN expression always needs an identification variable
View Full Code Here

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

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

      // Invalid conditional expression
      if (!isValid(conditionalExpression, ConditionalExpressionBNF.ID)) {

        int startPosition = position(expression) +
                            2 /* ON */ +
                            (expression.hasSpaceAfterIdentifier() ? 1 : 0);

        int endPosition = startPosition + length(conditionalExpression);

        addProblem(expression, startPosition, endPosition, OnClause_InvalidConditionalExpression);
      }
      // Validate the conditional expression
      else {
        conditionalExpression.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.