public final class AviatorEvaluator extends Object
| Modifier and Type | Field | Description |
|---|---|---|
static int |
BYTECODE_VER |
Deprecated.
|
static int |
COMPILE |
Optimized for compile speed
|
static int |
EVAL |
Optimized for execute speed,this is the default option
|
static Map<String,Object> |
FUNC_MAP |
Deprecated.
please use instance's field.
|
static Map<OperatorType,AviatorFunction> |
OPS_MAP |
Deprecated.
please use instance's field.
|
static String |
VERSION |
Aviator version
|
| Modifier and Type | Method | Description |
|---|---|---|
static void |
addFunction(AviatorFunction function) |
Add an aviator function,it's not thread-safe.
|
static void |
addFunctionLoader(FunctionLoader loader) |
Adds a function loader.
|
static List<String> |
addInstanceFunctions(String namespace,
Class<?> clazz) |
|
static void |
addOpFunction(OperatorType opType,
AviatorFunction function) |
Add an operator aviator function,it's not thread-safe.
|
static List<String> |
addStaticFunctions(String namespace,
Class<?> clazz) |
|
static void |
clearExpressionCache() |
Clear all cached compiled expression
|
static Expression |
compile(String expression) |
Compile a text expression to Expression Object without caching
|
static Expression |
compile(String expression,
boolean cached) |
Compile a text expression to Expression object
|
static boolean |
containsFunction(String name) |
Check if the function is existed in aviator
|
static void |
defineFunction(String name,
String expression) |
Define a function by name and expression.
|
static void |
defineFunction(String name,
String expression,
Map<String,Object> env) |
Define a function by name and expression with the execution env.
|
static Object |
exec(String expression,
Object... values) |
Deprecated.
|
static Object |
execute(String expression) |
Execute a text expression without caching and env map.
|
static Object |
execute(String expression,
Map<String,Object> env) |
Execute a text expression without caching
|
static Object |
execute(String expression,
Map<String,Object> env,
boolean cached) |
Execute a text expression with environment
|
static AviatorClassLoader |
getAviatorClassLoader() |
Returns classloader
|
static AviatorClassLoader |
getAviatorClassLoader(boolean cached) |
Returns classloader
|
static Expression |
getCachedExpression(String expression) |
Returns a compiled expression in cache
|
static AviatorFunction |
getFunction(String name) |
Retrieve an aviator function by name,throw exception if not found or null.It's not thread-safe.
|
static FunctionMissing |
getFunctionMissing() |
|
static AviatorEvaluatorInstance |
getInstance() |
Get the default evaluator instance
|
static MathContext |
getMathContext() |
Deprecated.
Please use
getOption(Options) |
static AviatorFunction |
getOpFunction(OperatorType opType) |
Retrieve an operator aviator function by op type, return null if not found.It's not
thread-safe.
|
static <T> T |
getOption(Options opt) |
Deprecated.
|
static Options.Value |
getOptionValue(Options opt) |
Returns the current evaluator option value union, returns null if missing.
|
static OutputStream |
getTraceOutputStream() |
Get current trace output stream,default is System.out
|
static List<String> |
importFunctions(Class<?> clazz) |
|
static void |
invalidateCache(String expression) |
Invalidate expression cache
|
static Map<String,Object> |
newEnv(Object... args) |
A helper method to generate a env object.
|
static AviatorEvaluatorInstance |
newInstance() |
Create a aviator evaluator instance.
|
static AviatorFunction |
removeFunction(AviatorFunction function) |
Remove a aviator function
|
static AviatorFunction |
removeFunction(String name) |
Remove an aviator function by name,it's not thread-safe.
|
static void |
removeFunctionLoader(FunctionLoader loader) |
Removes a function loader.
|
static AviatorFunction |
removeOpFunction(OperatorType opType) |
Remove an operator aviator function by op type, it's not thread-safe.
|
static void |
setAviatorClassLoader(AviatorClassLoader aviatorClassLoader) |
Deprecated.
|
static void |
setBYTECODE_VER(int nversion) |
|
static void |
setFunctionMissing(FunctionMissing functionMissing) |
|
static void |
setMathContext(MathContext mathContext) |
Deprecated.
please use
setOption(Options, Object) |
static void |
setOptimize(int value) |
Deprecated.
please use
setOption(Options, Object) |
static void |
setOption(Options opt,
Object val) |
Adds a evaluator option
|
static void |
setTraceOutputStream(OutputStream traceOutputStream) |
Set trace output stream
|
static void |
validate(String script) |
public static final int COMPILE
public static final int EVAL
public static final String VERSION
@Deprecated public static final Map<String,Object> FUNC_MAP
AviatorEvaluatorInstance.getFuncMap()@Deprecated public static final Map<OperatorType,AviatorFunction> OPS_MAP
AviatorEvaluatorInstance.getOpsMap()@Deprecated public static int BYTECODE_VER
public static AviatorEvaluatorInstance newInstance()
public static AviatorEvaluatorInstance getInstance()
public static Map<String,Object> newEnv(Object... args)
args - public static void addFunctionLoader(FunctionLoader loader)
loader - FunctionLoaderpublic static void removeFunctionLoader(FunctionLoader loader)
loader - FunctionLoaderpublic static void setFunctionMissing(FunctionMissing functionMissing)
functionMissing - AviatorEvaluatorInstance.setFunctionMissing(FunctionMissing)public static FunctionMissing getFunctionMissing()
functionMissing - AviatorEvaluatorInstance#getFunctionMissing(FunctionMissing)public static void setOption(Options opt, Object val)
opt - val - Options@Deprecated public static <T> T getOption(Options opt)
getOptionValue(Options) instead.opt - public static Options.Value getOptionValue(Options opt)
opt - public static OutputStream getTraceOutputStream()
@Deprecated public static MathContext getMathContext()
getOption(Options)@Deprecated public static void setMathContext(MathContext mathContext)
setOption(Options, Object)mathContext - public static void setTraceOutputStream(OutputStream traceOutputStream)
traceOutputStream - @Deprecated public static void setOptimize(int value)
setOption(Options, Object)public static void setBYTECODE_VER(int nversion)
public static void clearExpressionCache()
public static AviatorClassLoader getAviatorClassLoader()
public static AviatorClassLoader getAviatorClassLoader(boolean cached)
public static List<String> addInstanceFunctions(String namespace, Class<?> clazz) throws IllegalAccessException, NoSuchMethodException
public static List<String> addStaticFunctions(String namespace, Class<?> clazz) throws IllegalAccessException, NoSuchMethodException
public static List<String> importFunctions(Class<?> clazz) throws IllegalAccessException, NoSuchMethodException
public static void addFunction(AviatorFunction function)
function - public static void defineFunction(String name, String expression)
name - the function nameexpression - the expression to be executed and it's result must be a function.public static 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 static AviatorFunction removeFunction(String name)
name - public static AviatorFunction getFunction(String name)
name - public static void addOpFunction(OperatorType opType, AviatorFunction function)
function - public static AviatorFunction getOpFunction(OperatorType opType)
opType - public static AviatorFunction removeOpFunction(OperatorType opType)
opType - public static boolean containsFunction(String name)
name - public static AviatorFunction removeFunction(AviatorFunction function)
function - @Deprecated public static void setAviatorClassLoader(AviatorClassLoader aviatorClassLoader)
aviatorClassLoader - public static Expression getCachedExpression(String expression)
expression - public static Expression compile(String expression, boolean cached)
expression - text expressioncached - Whether to cache the compiled result,make true to cache it.public static Expression compile(String expression)
expression - public static void validate(String script)
script - AviatorEvaluatorInstance.validate(String)@Deprecated public static Object exec(String expression, Object... values)
execute(String, Map) instead.expression - values - public static 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 static Object execute(String expression, Map<String,Object> env)
expression - env - public static void invalidateCache(String expression)
expression - Copyright © 2022–2023. All rights reserved.