Package org.springframework.expression.spel.ast

Examples of org.springframework.expression.spel.ast.SpelNodeImpl


    Token t = peekToken();
    if (!peekSelectToken()) {
      return false;
    }
    nextToken();
    SpelNodeImpl expr = eatExpression();
    eatToken(TokenKind.RSQUARE);
    if (t.kind==TokenKind.SELECT_FIRST) {     
      constructedNodes.push(new Selection(nullSafeNavigation,Selection.FIRST,toPos(t),expr));
    } else if (t.kind==TokenKind.SELECT_LAST) {
      constructedNodes.push(new Selection(nullSafeNavigation,Selection.LAST,toPos(t),expr));
View Full Code Here


  //constructor 
    //:  ('new' qualifiedId LPAREN) => 'new' qualifiedId ctorArgs -> ^(CONSTRUCTOR qualifiedId ctorArgs)
  private boolean maybeEatConstructorReference() {
    if (peekIdentifierToken("new")) {
      Token newToken = nextToken();
      SpelNodeImpl possiblyQualifiedConstructorName = eatPossiblyQualifiedId();
      List<SpelNodeImpl> nodes = new ArrayList<SpelNodeImpl>();
      nodes.add(possiblyQualifiedConstructorName);
      if (peekToken(TokenKind.LSQUARE)) {
        // array initializer
        List<SpelNodeImpl> dimensions = new ArrayList<SpelNodeImpl>();
View Full Code Here

  //parenExpr : LPAREN! expression RPAREN!;
  private boolean maybeEatParenExpression() {
    if (peekToken(TokenKind.LPAREN)) {
      nextToken();
      SpelNodeImpl expr = eatExpression();
      eatToken(TokenKind.RPAREN);
      push(expr);
      return true;
    } else {
      return false;
View Full Code Here

      tokenizer.process();
      this.tokenStream = tokenizer.getTokens();
      this.tokenStreamLength = this.tokenStream.size();
      this.tokenStreamPointer = 0;
      this.constructedNodes.clear();
      SpelNodeImpl ast = eatExpression();
      if (moreTokens()) {
        throw new SpelParseException(peekToken().startPos, SpelMessage.MORE_INPUT, toString(nextToken()));
      }
      Assert.isTrue(this.constructedNodes.isEmpty());
      return new SpelExpression(expressionString, ast, this.configuration);
View Full Code Here

  //      ( (ASSIGN^ logicalOrExpression)
  //      | (DEFAULT^ logicalOrExpression)
  //      | (QMARK^ expression COLON! expression)
  //      | (ELVIS^ expression))?;
  private SpelNodeImpl eatExpression() {
    SpelNodeImpl expr = eatLogicalOrExpression();
    if (moreTokens()) {
      Token t = peekToken();
      if (t.kind == TokenKind.ASSIGN) {  // a=b
        if (expr == null) {
          expr = new NullLiteral(toPos(t.startPos - 1, t.endPos - 1));
        }
        nextToken();
        SpelNodeImpl assignedValue = eatLogicalOrExpression();
        return new Assign(toPos(t), expr, assignedValue);
      }

      if (t.kind == TokenKind.ELVIS) {  // a?:b (a if it isn't null, otherwise b)
        if (expr == null) {
          expr = new NullLiteral(toPos(t.startPos - 1, t.endPos - 2));
        }
        nextToken()// elvis has left the building
        SpelNodeImpl valueIfNull = eatExpression();
        if (valueIfNull==null) {
          valueIfNull = new NullLiteral(toPos(t.startPos + 1, t.endPos + 1));
        }
        return new Elvis(toPos(t), expr, valueIfNull);
      }

      if (t.kind == TokenKind.QMARK) {  // a?b:c
        if (expr == null) {
          expr = new NullLiteral(toPos(t.startPos - 1, t.endPos - 1));
        }
        nextToken();
        SpelNodeImpl ifTrueExprValue = eatExpression();
        eatToken(TokenKind.COLON);
        SpelNodeImpl ifFalseExprValue = eatExpression();
        return new Ternary(toPos(t), expr, ifTrueExprValue, ifFalseExprValue);
      }
    }
    return expr;
  }
View Full Code Here

    return expr;
  }

  //logicalOrExpression : logicalAndExpression (OR^ logicalAndExpression)*;
  private SpelNodeImpl eatLogicalOrExpression() {
    SpelNodeImpl expr = eatLogicalAndExpression();
    while (peekIdentifierToken("or") || peekToken(TokenKind.SYMBOLIC_OR)) {
      Token t = nextToken()//consume OR
      SpelNodeImpl rhExpr = eatLogicalAndExpression();
      checkOperands(t, expr, rhExpr);
      expr = new OpOr(toPos(t), expr, rhExpr);
    }
    return expr;
  }
View Full Code Here

    return expr;
  }

  // logicalAndExpression : relationalExpression (AND^ relationalExpression)*;
  private SpelNodeImpl eatLogicalAndExpression() {
    SpelNodeImpl expr = eatRelationalExpression();
    while (peekIdentifierToken("and") || peekToken(TokenKind.SYMBOLIC_AND)) {
      Token t = nextToken()// consume 'AND'
      SpelNodeImpl rhExpr = eatRelationalExpression();
      checkOperands(t, expr, rhExpr);
      expr = new OpAnd(toPos(t), expr, rhExpr);
    }
    return expr;
  }
View Full Code Here

    return expr;
  }

  // relationalExpression : sumExpression (relationalOperator^ sumExpression)?;
  private SpelNodeImpl eatRelationalExpression() {
    SpelNodeImpl expr = eatSumExpression();
    Token relationalOperatorToken = maybeEatRelationalOperator();
    if (relationalOperatorToken != null) {
      Token t = nextToken()// consume relational operator token
      SpelNodeImpl rhExpr = eatSumExpression();
      checkOperands(t, expr, rhExpr);
      TokenKind tk = relationalOperatorToken.kind;

      if (relationalOperatorToken.isNumericRelationalOperator()) {
        int pos = toPos(t);
View Full Code Here

    return expr;
  }

  //sumExpression: productExpression ( (PLUS^ | MINUS^) productExpression)*;
  private SpelNodeImpl eatSumExpression() {
    SpelNodeImpl expr = eatProductExpression();
    while (peekToken(TokenKind.PLUS, TokenKind.MINUS, TokenKind.INC)) {
      Token t = nextToken();//consume PLUS or MINUS or INC
      SpelNodeImpl rhExpr = eatProductExpression();
      checkRightOperand(t,rhExpr);
      if (t.kind == TokenKind.PLUS) {
        expr = new OpPlus(toPos(t), expr, rhExpr);
      }
      else if (t.kind == TokenKind.MINUS) {
View Full Code Here

    return expr;
  }

  // productExpression: powerExpr ((STAR^ | DIV^| MOD^) powerExpr)* ;
  private SpelNodeImpl eatProductExpression() {
    SpelNodeImpl expr = eatPowerIncDecExpression();
    while (peekToken(TokenKind.STAR, TokenKind.DIV, TokenKind.MOD)) {
      Token t = nextToken()// consume STAR/DIV/MOD
      SpelNodeImpl rhExpr = eatPowerIncDecExpression();
      checkOperands(t, expr, rhExpr);
      if (t.kind == TokenKind.STAR) {
        expr = new OpMultiply(toPos(t), expr, rhExpr);
      }
      else if (t.kind == TokenKind.DIV) {
View Full Code Here

TOP

Related Classes of org.springframework.expression.spel.ast.SpelNodeImpl

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.