Interface EvaluationContext
- All Known Implementing Classes:
BeanContext, ChainedContext, MapContext, StandardContext
public interface EvaluationContext
Evaluation Context Interface
求值上下文接口
Provides the runtime environment for expression evaluation including variables, functions, property accessors, and security sandbox.
提供表达式求值的运行时环境,包括变量、函数、属性访问器和安全沙箱。
Features | 主要功能:
- Variable management (get, set, check) - 变量管理(获取、设置、检查)
- Root object binding for property access - 根对象绑定用于属性访问
- Function registry for built-in and custom functions - 函数注册表,支持内置和自定义函数
- Property accessor SPI for custom types - 属性访问器SPI用于自定义类型
- Security sandbox integration - 安全沙箱集成
- Child context creation for scoped evaluation - 子上下文创建用于作用域求值
Usage Examples | 使用示例:
EvaluationContext ctx = new StandardContext();
ctx.setVariable("x", 10);
ctx.setVariable("y", 20);
Object result = OpenExpression.eval("x + y", ctx); // 30
Security | 安全性:
- Thread-safe: Depends on implementation - 线程安全: 取决于实现
- Null-safe: Depends on implementation - 空值安全: 取决于实现
- Since:
- JDK 25, opencode-base-expression V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionCreate child context 创建子上下文Get function registry 获取函数注册表Get property accessors 获取属性访问器Get the root object 获取根对象Get security sandbox 获取安全沙箱Get type converter 获取类型转换器getVariable(String name) Get variable value 获取变量值Get all variables 获取所有变量booleanhasVariable(String name) Check if variable exists 检查变量是否存在voidsetRootObject(Object root) Set the root object 设置根对象voidsetVariable(String name, Object value) Set variable value 设置变量值
-
Method Details
-
getRootObject
-
setRootObject
-
getVariable
-
setVariable
-
hasVariable
Check if variable exists 检查变量是否存在- Parameters:
name- the variable name | 变量名- Returns:
- true if exists | 如果存在返回true
-
getVariables
-
getFunctionRegistry
FunctionRegistry getFunctionRegistry()Get function registry 获取函数注册表- Returns:
- the function registry | 函数注册表
-
getPropertyAccessors
List<PropertyAccessor> getPropertyAccessors()Get property accessors 获取属性访问器- Returns:
- the property accessor list | 属性访问器列表
-
getTypeConverter
-
getSandbox
Sandbox getSandbox()Get security sandbox 获取安全沙箱- Returns:
- the sandbox, or null if not configured | 沙箱,如果未配置则返回null
-
createChild
EvaluationContext createChild()Create child context 创建子上下文Creates a child context that inherits from this context but can have its own variable bindings. Used for collection operations.
创建继承自此上下文但可以有自己变量绑定的子上下文。用于集合操作。
- Returns:
- the child context | 子上下文
-