ScriptExpression extends AbstractExpression<T> { public T evaluate(Object target, Map<String, Object> variables) { SimpleBindings bindings = variables == null ? new SimpleBindings() : new SimpleBindings(variables); bindings.put("target", target); try { return (T) (script == null ? scriptEngine.eval(getExpression(), bindings) : script.eval(bindings)); } catch (ScriptException e) { throw new RuntimeException(e); } } ScriptExpression();  ScriptExpression(String expression);  ScriptExpression(InputStream script);  ScriptExpression(String expression, String language);  ScriptExpression(InputStream script, String language); T evaluate(Object target, Map<String, Object> variables); void evaluateAndSet(Object target, Object value); void readExternal(PofReader reader); void writeExternal(PofWriter writer);  }
@Test public void testExpressionFromStream() { ByteArrayInputStream in = new ByteArrayInputStream("5 + 5".getBytes()); Expression exp = new ScriptExpression(in); assertEquals(10, ((Number) exp.evaluate(null)).intValue()); }