/** * Evaluates the specified String expression and returns the result. For example: * <pre class="groovyTestCase"> * assert Eval.me(' 2 * 4 + 2') == 10 * </pre> * @param expression the Groovy expression to evaluate * @return the result of the expression * @throws CompilationFailedException if expression is not valid Groovy */ public static Object me(final String expression) throws CompilationFailedException { return me(null, null, expression); }
/** * Evaluates the specified String expression and makes the parameter available inside * the script bound to a variable named 'x', returning the result. For example, this * code executes without failure: * <pre class="groovyTestCase"> * assert Eval.x(2, ' x * 4 + 2') == 10 * </pre> * @param expression the Groovy expression to evaluate * @return the result of the expression * @throws CompilationFailedException if expression is not valid Groovy */ public static Object x(final Object x, final String expression) throws CompilationFailedException { return me("x", x, expression); }
public void testMeSimple() throws CompilationFailedException { Object result = Eval.me("10"); assertEquals("10", result.toString()); }
public void testMeWithSymbolAndObject() throws CompilationFailedException { Object result = Eval.me("x", new Integer(10), "x"); assertEquals("10", result.toString()); }
/** * @param expression the Groovy expression to evaluate * @return the result of the expression * @throws CompilationFailedException if expression is no proper Groovy */ public static Object me(final String expression) throws CompilationFailedException { return me(null, null, expression); }
/** * evaluate expression and make x available inside the expression as 'x' * @param expression the Groovy expression to evaluate * @return the result of the expression * @throws CompilationFailedException if expression is no proper Groovy */ public static Object x(final Object x, final String expression) throws CompilationFailedException { return me("x", x, expression); }
/** * evaluate expression and make x available inside the expression as 'x' * @param expression the Groovy expression to evaluate * @return the result of the expression * @throws CompilationFailedException if expression is no proper Groovy */ public static Object x(final Object x, final String expression) throws CompilationFailedException { return me("x", x, expression); }
/** * evaluate expression and make x available inside the expression as 'x' * @param expression the Groovy expression to evaluate * @return the result of the expression * @throws CompilationFailedException if expression is no proper Groovy */ public static Object x(final Object x, final String expression) throws CompilationFailedException { return me("x", x, expression); }
/** * Evaluates the specified String expression and returns the result. For example: * <pre> * assert 10 == Eval.me(' 2 * 4 + 2') * </pre> * @param expression the Groovy expression to evaluate * @return the result of the expression * @throws CompilationFailedException if expression is not valid Groovy */ public static Object me(final String expression) throws CompilationFailedException { return me(null, null, expression); }
/** * @param expression the Groovy expression to evaluate * @return the result of the expression * @throws CompilationFailedException if expression is no proper Groovy */ public static Object me(final String expression) throws CompilationFailedException { return me(null, null, expression); }
/** * @param expression the Groovy expression to evaluate * @return the result of the expression * @throws CompilationFailedException if expression is no proper Groovy */ public static Object me(final String expression) throws CompilationFailedException { return me(null, null, expression); }
/** * Evaluates the specified String expression and makes the parameter available inside * the script bound to a variable named 'x', returning the result. For example, this * code executes without failure: * <pre> * assert 10 == Eval.x(2, ' x * 4 + 2') * </pre> * @param expression the Groovy expression to evaluate * @return the result of the expression * @throws CompilationFailedException if expression is not valid Groovy */ public static Object x(final Object x, final String expression) throws CompilationFailedException { return me("x", x, expression); }