Examples of Operator


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

    evaluate("new java.math.BigDecimal('5') ^ 3", new BigDecimal("125"), BigDecimal.class);
  }

  @Test
  public void testOperatorNames() throws Exception {
    Operator node = getOperatorNode((SpelExpression)parser.parseExpression("1==3"));
    assertEquals("==",node.getOperatorName());

    node = getOperatorNode((SpelExpression)parser.parseExpression("1!=3"));
    assertEquals("!=",node.getOperatorName());

    node = getOperatorNode((SpelExpression)parser.parseExpression("3/3"));
    assertEquals("/",node.getOperatorName());

    node = getOperatorNode((SpelExpression)parser.parseExpression("3+3"));
    assertEquals("+",node.getOperatorName());

    node = getOperatorNode((SpelExpression)parser.parseExpression("3-3"));
    assertEquals("-",node.getOperatorName());

    node = getOperatorNode((SpelExpression)parser.parseExpression("3<4"));
    assertEquals("<",node.getOperatorName());

    node = getOperatorNode((SpelExpression)parser.parseExpression("3<=4"));
    assertEquals("<=",node.getOperatorName());

    node = getOperatorNode((SpelExpression)parser.parseExpression("3*4"));
    assertEquals("*",node.getOperatorName());

    node = getOperatorNode((SpelExpression)parser.parseExpression("3%4"));
    assertEquals("%",node.getOperatorName());

    node = getOperatorNode((SpelExpression)parser.parseExpression("3>=4"));
    assertEquals(">=",node.getOperatorName());

    node = getOperatorNode((SpelExpression)parser.parseExpression("3 between 4"));
    assertEquals("between",node.getOperatorName());

    node = getOperatorNode((SpelExpression)parser.parseExpression("3 ^ 4"));
    assertEquals("^",node.getOperatorName());
  }
View Full Code Here

Examples of org.teiid.language.Comparison.Operator

        }
        throw new AssertionError();
    }

    org.teiid.language.Comparison translate(CompareCriteria criteria) {
        Operator operator = Operator.EQ;
        switch(criteria.getOperator()) {
            case CompareCriteria.EQ:   
                operator = Operator.EQ;
                break;
            case CompareCriteria.NE:   
View Full Code Here

Examples of org.zkoss.zuss.metainfo.Operator

          if (xtype == FUNC || xtype == COMMA)
            break;
          if (xtype == LPAREN)
            throw error("')' expected", xop);
          ops.remove(0);
          new Operator(expr, xop.getValue(), xop.getLine());
        }
        ops.add(0, new Op(COMMA, token.getLine()));
        opExpected = false;
        continue;
      }
      if (opExpected && (token instanceof Id || token instanceof Other)) {
        putback(token);
        token = new Op(CONCAT, token.getLine());
      }
      if (token instanceof Op) {
        final Op op = (Op)token;
        if (!opExpected) {
          switch (op.getValue()) {
          case LPAREN:
            ops.add(0, op);
            continue; //next
          case SUBTRACT:
            op.setValue(NEGATE);
            break;
          case ADD:
            continue; //ignore
          default:
            throw error("an operand expected, not "+op, op);
          }
        } else if (op.getValue() == RPAREN) {
          int argc = 1; //zero argument has been processed when Id is found
          l_pop:
          while (!ops.isEmpty()) {
            final Op xop = ops.remove(0);
            switch (xop.getValue()) {
            case FUNC:
              new FunctionValue(expr, xop.getData(), argc, xop.getLine());
              //fall thru
            case LPAREN:
              break l_pop; //done
            case COMMA:
              ++argc;
              break;
            default:
              new Operator(expr, xop.getValue(), xop.getLine());
            }
          }
          if (endcc == EOPAREN && ops.isEmpty())
            break; //done
          continue; //next token
        } else if (op.getValue() == LPAREN)
          throw error("unexpected '('", op);

        //push an operator
        while (!ops.isEmpty()) {
          final Op xop = ops.get(0);
          final Operator.Type xtype = xop.getValue();
          if (xtype.getPrecedence() > op.getValue().getPrecedence())
            break;
          //move ops[0] to expression since the precedence is GE
          ops.remove(0);
          new Operator(expr, xop.getValue(), xop.getLine());
        }
        ops.add(0, op);
        opExpected = false;
      } else {
        if (opExpected)
          throw error("an operator expected, not "+token, token);

        if (token instanceof Id) {
          final String nm = ((Id)token).getValue();
          Token t = next(ctx);
          if (!(t instanceof Op) || ((Op)t).getValue() != LPAREN) {
            putback(t);
            new FunctionValue(expr, nm, token.getLine()); //no parenthesis
          } else { //function invocation
            t = next(ctx);
            if (t instanceof Op && ((Op)t).getValue() == RPAREN) {
              //handle no arg invocation special, since it is not easy
              //to tell the difference between f(a) vs. f()
              new FunctionValue(expr, nm, 0, token.getLine()); //empty parenthesis
              if (endcc == EOPAREN && ops.isEmpty())
                break; //done
            } else {
              putback(t);
              ops.add(0, new Op(FUNC, nm, token.getLine())); //pass name as op's data
              continue; //opExpected still false
            }
          }
        } else if (token instanceof Other)
          new ConstantValue(expr, ((Other)token).getValue(), token.getLine());
        else
          throw error("unexpected "+token, token);
        opExpected = true;
      }
    }

    while (!ops.isEmpty()) {
      final Op xop = ops.remove(0);
      final Operator.Type xtype = xop.getValue();
      if (xtype == COMMA)
        throw error("unexpected ','", xop);
      if (xtype == LPAREN || xtype == FUNC)
        throw error("')' expected", xop);
      new Operator(expr, xtype, xop.getLine());
    }

    if (expr.getChildren().isEmpty())
      throw error("an expression expected", expr.getLine());
  }
View Full Code Here

Examples of plan_runner.operators.Operator

  }

  private static List<Operator> orderOperators(ChainOperator chain) {
    final List<Operator> result = new ArrayList<Operator>();

    final Operator selection = chain.getSelection();
    if (selection != null)
      result.add(selection);

    final Operator distinct = chain.getDistinct();
    if (distinct != null)
      result.add(distinct);

    final Operator projection = chain.getProjection();
    if (projection != null)
      result.add(projection);

    final Operator agg = chain.getAggregation();
    if (agg != null)
      result.add(agg);

    return result;
  }
View Full Code Here

Examples of plan_runner.operators.Operator

  @Override
  public void aggBatchSend() {
    if (MyUtilities.isAggBatchOutputMode(_aggBatchOutputMillis))
      if (_operatorChain != null) {
        final Operator lastOperator = _operatorChain.getLastOperator();
        if (lastOperator instanceof AggregateOperator) {
          try {
            _semAgg.acquire();
          } catch (final InterruptedException ex) {
          }
View Full Code Here

Examples of plan_runner.operators.Operator

  @Override
  public void aggBatchSend() {
    if (MyUtilities.isAggBatchOutputMode(_aggBatchOutputMillis))
      if (_operatorChain != null) {
        final Operator lastOperator = _operatorChain.getLastOperator();
        if (lastOperator instanceof AggregateOperator) {
          try {
            _semAgg.acquire();
          } catch (final InterruptedException ex) {
          }
View Full Code Here

Examples of plan_runner.operators.Operator

  @Override
  public void printContent() {
    if (_printOut)
      if ((getChainOperator() != null) && getChainOperator().isBlocking()) {
        final Operator lastOperator = getChainOperator().getLastOperator();
        if (lastOperator instanceof AggregateOperator)
          MyUtilities.printBlockingResult(_ID, (AggregateOperator) lastOperator,
              _hierarchyPosition, _conf, LOG);
        else
          MyUtilities.printBlockingResult(_ID, lastOperator.getNumTuplesProcessed(),
              lastOperator.printContent(), _hierarchyPosition, _conf, LOG);
      }
  }
View Full Code Here

Examples of plan_runner.operators.Operator

  @Override
  public void aggBatchSend() {
    if (MyUtilities.isAggBatchOutputMode(_aggBatchOutputMillis))
      if (_operatorChain != null) {
        final Operator lastOperator = _operatorChain.getLastOperator();
        if (lastOperator instanceof AggregateOperator) {
          try {
            _semAgg.acquire();
          } catch (final InterruptedException ex) {
          }
View Full Code Here

Examples of plan_runner.operators.Operator

  @Override
  public void aggBatchSend() {
    if (MyUtilities.isAggBatchOutputMode(_aggBatchOutputMillis))
      if (_operatorChain != null) {
        final Operator lastOperator = _operatorChain.getLastOperator();
        if (lastOperator instanceof AggregateOperator) {
          try {
            _semAgg.acquire();
          } catch (final InterruptedException ex) {
          }
View Full Code Here

Examples of solver.constraints.Operator

     * Generate valid tuples for VAR1 OP VAR2, where OP in {"=", "!=", ">","<",">=","<="}
     *
     * @return a Tuples object, reserved for a table constraint
     */
    public static Tuples arithm(IntVar VAR1, String OP, IntVar VAR2) {
        final Operator op = Operator.get(OP);
        return generateTuples(new TupleValidator() {
            @Override
            public boolean valid(int... values) {
                switch (op) {
                    case LT:
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.