Package org.springframework.binding.expression

Examples of org.springframework.binding.expression.ExpressionVariable


    if (variables == null || variables.length == 0) {
      return null;
    }
    Map variableExpressions = new HashMap(variables.length, 1);
    for (int i = 0; i < variables.length; i++) {
      ExpressionVariable var = variables[i];
      variableExpressions.put(var.getName(), parseExpression(var.getValueExpression(), var.getParserContext()));
    }
    return variableExpressions;
  }
View Full Code Here


  }

  public void testParseTemplateExpressionWithVariables() {
    String expressionString = "#{value}#{max}";
    Expression exp = parser.parseExpression(expressionString, new FluentParserContext().template().variable(
        new ExpressionVariable("max", "maximum")));
    TestBean target = new TestBean();
    assertEquals("foo2", exp.getValue(target));
  }
View Full Code Here

    TestBean target = new TestBean();
    assertEquals("foo2", exp.getValue(target));
  }

  public void testVariablesWithCoersion() {
    Expression exp = parser.parseExpression("max", new FluentParserContext().variable(new ExpressionVariable("max",
        "maximum", new FluentParserContext().expectResult(Long.class))));
    TestBean target = new TestBean();
    assertEquals(new Long(2), exp.getValue(target));
  }
View Full Code Here

  }

  public void testTemplateNestedVariables() {
    String expressionString = "#{value}#{max}";
    Expression exp = parser.parseExpression(expressionString, new FluentParserContext().template().variable(
        new ExpressionVariable("max", "#{maximum}#{var}", new FluentParserContext().template().variable(
            new ExpressionVariable("var", "'bar'")))));
    TestBean target = new TestBean();
    assertEquals("foo2bar", exp.getValue(target));
  }
View Full Code Here

    parser.parseExpression("${b,#{1:2}}", new FluentParserContext().template());
    parser.parseExpression("a${b,#{1:2},e}f${g,#{3:4},j}k", new FluentParserContext().template());
  }

  public void testVariables() {
    Expression exp = parser.parseExpression("#var", new FluentParserContext().variable(new ExpressionVariable(
        "var", "flag")));
    assertEquals(false, ((Boolean) exp.getValue(bean)).booleanValue());
  }
View Full Code Here

        "var", "flag")));
    assertEquals(false, ((Boolean) exp.getValue(bean)).booleanValue());
  }

  public void testVariablesWithCoersion() {
    Expression exp = parser.parseExpression("#var", new FluentParserContext().variable(new ExpressionVariable(
        "var", "number", new FluentParserContext().expectResult(Long.class))));
    assertEquals(new Long(0), exp.getValue(bean));
  }
View Full Code Here

        "var", "number", new FluentParserContext().expectResult(Long.class))));
    assertEquals(new Long(0), exp.getValue(bean));
  }

  public void testNestedVariablesWithTemplates() {
    Expression exp = parser.parseExpression("#var", new FluentParserContext().variable(new ExpressionVariable(
        "var", "${flag}${#var}", new FluentParserContext().template().variable(
            new ExpressionVariable("var", "number")))));
    assertEquals("false0", exp.getValue(bean));
  }
View Full Code Here

    public void mapVariables(ExpressionVariable[] variables, ExpressionFactory expressionFactory) {
      if (variables != null && variables.length > 0) {
        variableMapper = new VariableMapperImpl();
        for (int i = 0; i < variables.length; i++) {
          ExpressionVariable var = variables[i];
          ParserContext context = var.getParserContext() != null ? var.getParserContext()
              : NullParserContext.INSTANCE;
          ValueExpression expr;
          if (context.isTemplate()) {
            expr = parseValueExpression(var.getValueExpression(), context);
          } else {
            assertNotDelimited(var.getValueExpression());
            assertHasText(var.getValueExpression());
            expr = parseValueExpression("#{" + var.getValueExpression() + "}", context);
          }
          variableMapper.setVariable(var.getName(), expr);
        }
      }
    }
View Full Code Here

  }

  public void testParseTemplateExpressionWithVariables() {
    String expressionString = "#{value}#{max}";
    Expression exp = parser.parseExpression(expressionString,
        new FluentParserContext().template().variable(new ExpressionVariable("max", "maximum")));
    TestBean target = new TestBean();
    assertEquals("foo2", exp.getValue(target));
  }
View Full Code Here

    TestBean target = new TestBean();
    assertEquals("foo2", exp.getValue(target));
  }

  public void testVariablesWithCoersion() {
    Expression exp = parser.parseExpression("max", new FluentParserContext().variable(new ExpressionVariable("max",
        "maximum", new FluentParserContext().expectResult(Long.class))));
    TestBean target = new TestBean();
    assertEquals(new Long(2), exp.getValue(target));
  }
View Full Code Here

TOP

Related Classes of org.springframework.binding.expression.ExpressionVariable

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.