public class Eval
extends java.lang.Object
assert 10 == Eval.me(' 2 * 4 + 2') assert 10 == Eval.x(2, ' x * 4 + 2')
GroovyShell
Constructor | Description |
---|---|
Eval() |
Modifier and Type | Method | Description |
---|---|---|
static java.lang.Object |
me(java.lang.String expression) |
Evaluates the specified String expression and returns the result.
|
static java.lang.Object |
me(java.lang.String symbol,
java.lang.Object object,
java.lang.String expression) |
Evaluates the specified String expression and makes the parameter available inside
the script, returning the result.
|
static java.lang.Object |
x(java.lang.Object x,
java.lang.String expression) |
Evaluates the specified String expression and makes the parameter available inside
the script bound to a variable named 'x', returning the result.
|
static java.lang.Object |
xy(java.lang.Object x,
java.lang.Object y,
java.lang.String expression) |
Evaluates the specified String expression and makes the first two parameters available inside
the script bound to variables named 'x' and 'y' respectively, returning the result.
|
static java.lang.Object |
xyz(java.lang.Object x,
java.lang.Object y,
java.lang.Object z,
java.lang.String expression) |
Evaluates the specified String expression and makes the first three parameters available inside
the script bound to variables named 'x', 'y', and 'z' respectively, returning the result.
|
public static java.lang.Object me(java.lang.String expression) throws CompilationFailedException
assert 10 == Eval.me(' 2 * 4 + 2')
expression
- the Groovy expression to evaluateCompilationFailedException
- if expression is not valid Groovypublic static java.lang.Object me(java.lang.String symbol, java.lang.Object object, java.lang.String expression) throws CompilationFailedException
assert 10 == Eval.me('x', 2, ' x * 4 + 2')
expression
- the Groovy expression to evaluateCompilationFailedException
- if expression is not valid Groovypublic static java.lang.Object x(java.lang.Object x, java.lang.String expression) throws CompilationFailedException
assert 10 == Eval.x(2, ' x * 4 + 2')
expression
- the Groovy expression to evaluateCompilationFailedException
- if expression is not valid Groovypublic static java.lang.Object xy(java.lang.Object x, java.lang.Object y, java.lang.String expression) throws CompilationFailedException
assert 10 == Eval.xy(2, 4, ' x * y + 2')
expression
- the Groovy expression to evaluateCompilationFailedException
- if expression is not valid Groovypublic static java.lang.Object xyz(java.lang.Object x, java.lang.Object y, java.lang.Object z, java.lang.String expression) throws CompilationFailedException
assert 10 == Eval.xyz(2, 4, 2, ' x * y + z')
expression
- the Groovy expression to evaluateCompilationFailedException
- if expression is not valid Groovy