Package org.araneaframework.backend.list.memorybased.expression

Examples of org.araneaframework.backend.list.memorybased.expression.VariableResolver


    data.put("age", new Long(25));
    data.put("licenseToKill", Boolean.TRUE);
    Expression expr = filter.buildExpression(data);

    // evaluate expression in memory
    Object value = expr.evaluate(new VariableResolver() {
      public Object resolve(Variable variable) {
        if (variable.getName().equals("name")) {
          return "James Bond";
        }
        if (variable.getName().equals("age")) {
          return new Long(30);
        }
        if (variable.getName().equals("licenseToKill")) {
          return Boolean.TRUE;
        }
        return null;
      }
    });
    assertEquals(value, Boolean.TRUE);

    // evaluate expression in memory
    value = expr.evaluate(new VariableResolver() {
      public Object resolve(Variable variable) {
        if (variable.getName().equals("name")) {
          return "Bond, James";
        }
        return null;
      }
    });
    assertEquals(value, Boolean.FALSE);

    // build sql expression
    StandardExpressionToSqlExprBuilder builder = new StandardExpressionToSqlExprBuilder();
    builder.setMapper(new VariableResolver() {
      public Object resolve(Variable variable) {
        if ("name".equals(variable.getName())) {
          return "AGENT.NAME";
        }
        if ("age".equals(variable.getName())) {
View Full Code Here


            new ValueExpression(new Long(25)))).add(
        new EqualsExpression(new VariableExpression("licenseToKill"),
            new ValueExpression(Boolean.TRUE)));

    // evaluate expression in memory
    Object value = expr.evaluate(new VariableResolver() {
      public Object resolve(Variable variable) {
        if (variable.getName().equals("name")) {
          return "James Bond";
        }
        if (variable.getName().equals("age")) {
          return new Long(30);
        }
        if (variable.getName().equals("licenseToKill")) {
          return Boolean.TRUE;
        }
        return null;
      }
    });
    assertEquals(value, Boolean.TRUE);

    // evaluate expression in memory
    value = expr.evaluate(new VariableResolver() {
      public Object resolve(Variable variable) {
        if (variable.getName().equals("name")) {
          return "Bond, James";
        }
        return null;
      }
    });
    assertEquals(value, Boolean.FALSE);

    // build sql expression
    StandardExpressionToSqlExprBuilder builder = new StandardExpressionToSqlExprBuilder();
    builder.setMapper(new VariableResolver() {
      public Object resolve(Variable variable) {
        if ("name".equals(variable.getName())) {
          return "AGENT.NAME";
        }
        if ("age".equals(variable.getName())) {
View Full Code Here

TOP

Related Classes of org.araneaframework.backend.list.memorybased.expression.VariableResolver

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.