@Test public void testEvaluate() { Attribute attribute = new Attribute(); attribute.setExpressionObject(new Expression("requestScope.object1")); assertEquals("The value is not correct", "value", evaluator.evaluate( attribute, request)); attribute.setExpressionObject(new Expression("sessionScope.object2")); assertEquals("The value is not correct", new Integer(1), evaluator .evaluate(attribute, request)); attribute.setExpressionObject(new Expression("applicationScope.object3")); assertEquals("The value is not correct", new Float(2.0), evaluator .evaluate(attribute, request)); attribute.setExpressionObject(new Expression("object1")); assertEquals("The value is not correct", "value", evaluator.evaluate( attribute, request)); attribute.setExpressionObject(new Expression("object2")); assertEquals("The value is not correct", new Integer(1), evaluator .evaluate(attribute, request)); attribute.setExpressionObject(new Expression("object3")); assertEquals("The value is not correct", new Float(2.0), evaluator .evaluate(attribute, request)); attribute.setExpressionObject(new Expression("paulaBean.paula")); assertEquals("The value is not correct", "Brillant", evaluator .evaluate(attribute, request)); attribute.setExpressionObject(new Expression("'String literal'")); assertEquals("The value is not correct", "String literal", evaluator .evaluate(attribute, request)); attribute.setValue(new Integer(2)); assertEquals("The value is not correct", new Integer(2), evaluator .evaluate(attribute, request)); attribute.setValue("object1"); assertEquals("The value has been evaluated", "object1", evaluator .evaluate(attribute, request)); }
public Object evaluate(String expression, Request request) { if (expression == null) { throw new IllegalArgumentException("The expression parameter cannot be null"); } try { return Ognl.getValue(expression, request); } catch (OgnlException e) { throw new EvaluationException("Cannot evaluate OGNL expression '" + expression + "'", e); } }
OGNLAttributeEvaluator extends AbstractAttributeEvaluator { public Object evaluate(String expression, Request request) { if (expression == null) { throw new IllegalArgumentException("The expression parameter cannot be null"); } try { return Ognl.getValue(expression, request); } catch (OgnlException e) { throw new EvaluationException("Cannot evaluate OGNL expression '" + expression + "'", e); } } }
OGNLAttributeEvaluator extends AbstractAttributeEvaluator { public Object evaluate(String expression, Request request) { if (expression == null) { throw new IllegalArgumentException("The expression parameter cannot be null"); } try { return Ognl.getValue(expression, request); } catch (OgnlException e) { throw new EvaluationException("Cannot evaluate OGNL expression '" + expression + "'", e); } }  }
OGNLAttributeEvaluator extends AbstractAttributeEvaluator { public Object evaluate(String expression, Request request) { if (expression == null) { throw new IllegalArgumentException("The expression parameter cannot be null"); } try { return Ognl.getValue(expression, request); } catch (OgnlException e) { throw new EvaluationException("Cannot evaluate OGNL expression '" + expression + "'", e); } }  Object evaluate(String expression, Request request); }
OGNLAttributeEvaluator extends AbstractAttributeEvaluator { public Object evaluate(String expression, Request request) { if (expression == null) { throw new IllegalArgumentException("The expression parameter cannot be null"); } try { return Ognl.getValue(expression, request); } catch (OgnlException e) { throw new EvaluationException("Cannot evaluate OGNL expression '" + expression + "'", e); } }  Object evaluate(String expression, Request request);  }