public final class AviatorEvaluatorInstance extends Object
| Modifier and Type | Field and Description |
|---|---|
int |
bytecodeVersion
Generated java class version,default 1.6
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFunction(AviatorFunction function)
Add an aviator function,it's not thread-safe.
|
void |
addFunction(String name,
AviatorFunction function)
Adds a function with the name
|
void |
addFunctionLoader(FunctionLoader loader)
Adds a function loader
|
void |
addOpFunction(OperatorType opType,
AviatorFunction function)
Add an operator aviator function,it's not thread-safe.
|
void |
clearExpressionCache()
Clear all cached compiled expression
|
Expression |
compile(String expression)
Compile a text expression to Expression Object without caching
|
Expression |
compile(String expression,
boolean cached)
Compile a text expression to Expression object
|
boolean |
containsFunction(String name)
Check if the function is existed in aviator
|
void |
defineFunction(String name,
String expression)
Define a function by name and expression.
|
void |
defineFunction(String name,
String expression,
Map<String,Object> env)
Define a function by name and expression with the execution env.
|
Object |
exec(String expression,
Object... values)
Execute a text expression with values that are variables order in the expression.It only runs
in EVAL mode,and it will cache the compiled expression.
|
Object |
execute(String expression)
Execute a text expression without caching and env map.
|
Object |
execute(String expression,
Map<String,Object> env)
Execute a text expression without caching
|
Object |
execute(String expression,
Map<String,Object> env,
boolean cached)
Execute a text expression with environment
|
AviatorClassLoader |
getAviatorClassLoader()
Returns classloader
|
AviatorClassLoader |
getAviatorClassLoader(boolean cached)
Returns classloader
|
int |
getBytecodeVersion()
Returns the generated java classes byte code version, 1.6 by defualt.
|
Expression |
getCachedExpression(String expression)
Returns a compiled expression in cache
|
int |
getExpressionCacheSize()
Returns the number of cached expressions.
|
Map<String,Object> |
getFuncMap()
Returns the functions map
|
AviatorFunction |
getFunction(String name)
Retrieve an aviator function by name,throw exception if not found or null.It's not thread-safe.
|
AviatorFunction |
getOpFunction(OperatorType opType)
Retrieve an operator aviator function by op type, return null if not found.It's not
thread-safe.
|
Map<OperatorType,AviatorFunction> |
getOpsMap()
Returns the operators map.
|
<T> T |
getOption(Options opt)
Deprecated.
|
Map<Options,Object> |
getOptions()
Get the evaluator instance options
|
Options.Value |
getOptionValue(Options opt)
Returns the current evaluator option value union, returns null if missing.
|
OutputStream |
getTraceOutputStream()
Get current trace output stream,default is System.out
|
void |
invalidateCache(String expression)
Invalidate expression cache
|
boolean |
isExpressionCached(String expression)
Returns true when the expression is in cache.
|
CodeGenerator |
newCodeGenerator(AviatorClassLoader classLoader) |
CodeGenerator |
newCodeGenerator(boolean cached) |
AviatorFunction |
removeFunction(AviatorFunction function)
Remove a aviator function
|
AviatorFunction |
removeFunction(String name)
Remove an aviator function by name,it's not thread-safe.
|
void |
removeFunctionLoader(FunctionLoader loader)
Remove a function loader
|
AviatorFunction |
removeOpFunction(OperatorType opType)
Remove an operator aviator function by op type, it's not thread-safe.
|
void |
setBytecodeVersion(int bytecodeVersion)
Set the generated java classes java byte code version.
|
void |
setOption(Options opt,
Object val)
Adds a evaluator option
|
void |
setTraceOutputStream(OutputStream traceOutputStream)
Set trace output stream
|
public void addFunctionLoader(FunctionLoader loader)
loader - FunctionLoaderpublic void removeFunctionLoader(FunctionLoader loader)
loader - public void setOption(Options opt, Object val)
opt - val - Options@Deprecated public <T> T getOption(Options opt)
opt - public Options.Value getOptionValue(Options opt)
opt - public int getBytecodeVersion()
public void setBytecodeVersion(int bytecodeVersion)
bytecodeVersion - Opcodes.V1_6public Map<OperatorType,AviatorFunction> getOpsMap()
public OutputStream getTraceOutputStream()
public void setTraceOutputStream(OutputStream traceOutputStream)
traceOutputStream - public void clearExpressionCache()
public AviatorClassLoader getAviatorClassLoader()
public AviatorClassLoader getAviatorClassLoader(boolean cached)
public void addFunction(AviatorFunction function)
function - public void addFunction(String name, AviatorFunction function)
name - function - public void defineFunction(String name, String expression)
name - the function nameexpression - the expression to be executed and it's result must be a function.public void defineFunction(String name, String expression, Map<String,Object> env)
name - the function nameexpression - the expression to be executed and it's result must be a function.env - the expression execution envpublic AviatorFunction removeFunction(String name)
name - public AviatorFunction getFunction(String name)
name - public void addOpFunction(OperatorType opType, AviatorFunction function)
function - public AviatorFunction getOpFunction(OperatorType opType)
opType - public AviatorFunction removeOpFunction(OperatorType opType)
opType - public boolean containsFunction(String name)
name - public AviatorFunction removeFunction(AviatorFunction function)
function - public Expression getCachedExpression(String expression)
expression - public boolean isExpressionCached(String expression)
expression - public int getExpressionCacheSize()
public Expression compile(String expression, boolean cached)
expression - text expressioncached - Whether to cache the compiled result,make true to cache it.public CodeGenerator newCodeGenerator(boolean cached)
public CodeGenerator newCodeGenerator(AviatorClassLoader classLoader)
public Expression compile(String expression)
expression - public Object exec(String expression, Object... values)
expression - values - public Object execute(String expression, Map<String,Object> env, boolean cached)
expression - text expressionenv - Binding variable environmentcached - Whether to cache the compiled result,make true to cache it.public Object execute(String expression, Map<String,Object> env)
expression - env - public void invalidateCache(String expression)
expression - Copyright © 2019. All rights reserved.