接口 Expression
public interface Expression
An expression capable of evaluating itself against context objects. Encapsulates the details of a previously parsed expression string. Provides a common abstraction for expression evaluation.- 从以下版本开始:
- 3.0
- 作者:
- Keith Donald, Andy Clement, Juergen Hoeller
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 String
getExpressionString()
Return the original string used to create this expression (unmodified).Object
getValue()
Evaluate this expression in the default standard context.<T> T
getValue(Class<T> desiredResultType)
Evaluate the expression in the default context.Object
getValue(Object rootObject)
Evaluate this expression against the specified root object.<T> T
getValue(Object rootObject, Class<T> desiredResultType)
Evaluate the expression in the default context against the specified root object.Object
getValue(EvaluationContext context)
Evaluate this expression in the provided context and return the result of evaluation.<T> T
getValue(EvaluationContext context, Class<T> desiredResultType)
Evaluate the expression in a specified context which can resolve references to properties, methods, types, etc.Object
getValue(EvaluationContext context, Object rootObject)
Evaluate this expression in the provided context and return the result of evaluation, but use the supplied root context as an override for any default root object specified in the context.<T> T
getValue(EvaluationContext context, Object rootObject, Class<T> desiredResultType)
Evaluate the expression in a specified context which can resolve references to properties, methods, types, etc.Class<?>
getValueType()
Return the most general type that can be passed to asetValue(java.lang.Object, java.lang.Object)
method using the default context.Class<?>
getValueType(Object rootObject)
Return the most general type that can be passed to thesetValue(Object, Object)
method using the default context.Class<?>
getValueType(EvaluationContext context)
Return the most general type that can be passed to thesetValue(EvaluationContext, Object)
method for the given context.Class<?>
getValueType(EvaluationContext context, Object rootObject)
Return the most general type that can be passed to thesetValue(EvaluationContext, Object, Object)
method for the given context.TypeDescriptor
getValueTypeDescriptor()
Return the most general type that can be passed to asetValue(java.lang.Object, java.lang.Object)
method using the default context.TypeDescriptor
getValueTypeDescriptor(Object rootObject)
Return the most general type that can be passed to thesetValue(Object, Object)
method using the default context.TypeDescriptor
getValueTypeDescriptor(EvaluationContext context)
Return the most general type that can be passed to thesetValue(EvaluationContext, Object)
method for the given context.TypeDescriptor
getValueTypeDescriptor(EvaluationContext context, Object rootObject)
Return the most general type that can be passed to thesetValue(EvaluationContext, Object, Object)
method for the given context.boolean
isWritable(Object rootObject)
Determine if an expression can be written to, i.e. setValue() can be called.boolean
isWritable(EvaluationContext context)
Determine if an expression can be written to, i.e. setValue() can be called.boolean
isWritable(EvaluationContext context, Object rootObject)
Determine if an expression can be written to, i.e. setValue() can be called.void
setValue(Object rootObject, Object value)
Set this expression in the provided context to the value provided.void
setValue(EvaluationContext context, Object value)
Set this expression in the provided context to the value provided.void
setValue(EvaluationContext context, Object rootObject, Object value)
Set this expression in the provided context to the value provided.
方法详细资料
getExpressionString
String getExpressionString()
Return the original string used to create this expression (unmodified).- 返回:
- the original expression string
getValue
@Nullable Object getValue() throws EvaluationException
Evaluate this expression in the default standard context.- 返回:
- the evaluation result
- 抛出:
EvaluationException
- if there is a problem during evaluation
getValue
@Nullable <T> T getValue(@Nullable Class<T> desiredResultType) throws EvaluationException
Evaluate the expression in the default context. If the result of the evaluation does not match (and cannot be converted to) the expected result type then an exception will be returned.- 参数:
desiredResultType
- the class the caller would like the result to be- 返回:
- the evaluation result
- 抛出:
EvaluationException
- if there is a problem during evaluation
getValue
@Nullable Object getValue(@Nullable Object rootObject) throws EvaluationException
Evaluate this expression against the specified root object.- 参数:
rootObject
- the root object against which to evaluate the expression- 返回:
- the evaluation result
- 抛出:
EvaluationException
- if there is a problem during evaluation
getValue
@Nullable <T> T getValue(@Nullable Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException
Evaluate the expression in the default context against the specified root object. If the result of the evaluation does not match (and cannot be converted to) the expected result type then an exception will be returned.- 参数:
rootObject
- the root object against which to evaluate the expressiondesiredResultType
- the class the caller would like the result to be- 返回:
- the evaluation result
- 抛出:
EvaluationException
- if there is a problem during evaluation
getValue
@Nullable Object getValue(EvaluationContext context) throws EvaluationException
Evaluate this expression in the provided context and return the result of evaluation.- 参数:
context
- the context in which to evaluate the expression- 返回:
- the evaluation result
- 抛出:
EvaluationException
- if there is a problem during evaluation
getValue
@Nullable Object getValue(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException
Evaluate this expression in the provided context and return the result of evaluation, but use the supplied root context as an override for any default root object specified in the context.- 参数:
context
- the context in which to evaluate the expressionrootObject
- the root object against which to evaluate the expression- 返回:
- the evaluation result
- 抛出:
EvaluationException
- if there is a problem during evaluation
getValue
@Nullable <T> T getValue(EvaluationContext context, @Nullable Class<T> desiredResultType) throws EvaluationException
Evaluate the expression in a specified context which can resolve references to properties, methods, types, etc. The type of the evaluation result is expected to be of a particular class and an exception will be thrown if it is not and cannot be converted to that type.- 参数:
context
- the context in which to evaluate the expressiondesiredResultType
- the class the caller would like the result to be- 返回:
- the evaluation result
- 抛出:
EvaluationException
- if there is a problem during evaluation
getValue
@Nullable <T> T getValue(EvaluationContext context, @Nullable Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException
Evaluate the expression in a specified context which can resolve references to properties, methods, types, etc. The type of the evaluation result is expected to be of a particular class and an exception will be thrown if it is not and cannot be converted to that type. The supplied root object overrides any default specified on the supplied context.- 参数:
context
- the context in which to evaluate the expressionrootObject
- the root object against which to evaluate the expressiondesiredResultType
- the class the caller would like the result to be- 返回:
- the evaluation result
- 抛出:
EvaluationException
- if there is a problem during evaluation
getValueType
@Nullable Class<?> getValueType() throws EvaluationException
Return the most general type that can be passed to asetValue(java.lang.Object, java.lang.Object)
method using the default context.- 返回:
- the most general type of value that can be set on this context
- 抛出:
EvaluationException
- if there is a problem determining the type
getValueType
@Nullable Class<?> getValueType(@Nullable Object rootObject) throws EvaluationException
Return the most general type that can be passed to thesetValue(Object, Object)
method using the default context.- 参数:
rootObject
- the root object against which to evaluate the expression- 返回:
- the most general type of value that can be set on this context
- 抛出:
EvaluationException
- if there is a problem determining the type
getValueType
@Nullable Class<?> getValueType(EvaluationContext context) throws EvaluationException
Return the most general type that can be passed to thesetValue(EvaluationContext, Object)
method for the given context.- 参数:
context
- the context in which to evaluate the expression- 返回:
- the most general type of value that can be set on this context
- 抛出:
EvaluationException
- if there is a problem determining the type
getValueType
@Nullable Class<?> getValueType(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException
Return the most general type that can be passed to thesetValue(EvaluationContext, Object, Object)
method for the given context. The supplied root object overrides any specified in the context.- 参数:
context
- the context in which to evaluate the expressionrootObject
- the root object against which to evaluate the expression- 返回:
- the most general type of value that can be set on this context
- 抛出:
EvaluationException
- if there is a problem determining the type
getValueTypeDescriptor
@Nullable TypeDescriptor getValueTypeDescriptor() throws EvaluationException
Return the most general type that can be passed to asetValue(java.lang.Object, java.lang.Object)
method using the default context.- 返回:
- a type descriptor for values that can be set on this context
- 抛出:
EvaluationException
- if there is a problem determining the type
getValueTypeDescriptor
@Nullable TypeDescriptor getValueTypeDescriptor(@Nullable Object rootObject) throws EvaluationException
Return the most general type that can be passed to thesetValue(Object, Object)
method using the default context.- 参数:
rootObject
- the root object against which to evaluate the expression- 返回:
- a type descriptor for values that can be set on this context
- 抛出:
EvaluationException
- if there is a problem determining the type
getValueTypeDescriptor
@Nullable TypeDescriptor getValueTypeDescriptor(EvaluationContext context) throws EvaluationException
Return the most general type that can be passed to thesetValue(EvaluationContext, Object)
method for the given context.- 参数:
context
- the context in which to evaluate the expression- 返回:
- a type descriptor for values that can be set on this context
- 抛出:
EvaluationException
- if there is a problem determining the type
getValueTypeDescriptor
@Nullable TypeDescriptor getValueTypeDescriptor(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException
Return the most general type that can be passed to thesetValue(EvaluationContext, Object, Object)
method for the given context. The supplied root object overrides any specified in the context.- 参数:
context
- the context in which to evaluate the expressionrootObject
- the root object against which to evaluate the expression- 返回:
- a type descriptor for values that can be set on this context
- 抛出:
EvaluationException
- if there is a problem determining the type
isWritable
boolean isWritable(@Nullable Object rootObject) throws EvaluationException
Determine if an expression can be written to, i.e. setValue() can be called.- 参数:
rootObject
- the root object against which to evaluate the expression- 返回:
true
if the expression is writable;false
otherwise- 抛出:
EvaluationException
- if there is a problem determining if it is writable
isWritable
boolean isWritable(EvaluationContext context) throws EvaluationException
Determine if an expression can be written to, i.e. setValue() can be called.- 参数:
context
- the context in which the expression should be checked- 返回:
true
if the expression is writable;false
otherwise- 抛出:
EvaluationException
- if there is a problem determining if it is writable
isWritable
boolean isWritable(EvaluationContext context, @Nullable Object rootObject) throws EvaluationException
Determine if an expression can be written to, i.e. setValue() can be called. The supplied root object overrides any specified in the context.- 参数:
context
- the context in which the expression should be checkedrootObject
- the root object against which to evaluate the expression- 返回:
true
if the expression is writable;false
otherwise- 抛出:
EvaluationException
- if there is a problem determining if it is writable
setValue
void setValue(@Nullable Object rootObject, @Nullable Object value) throws EvaluationException
Set this expression in the provided context to the value provided.- 参数:
rootObject
- the root object against which to evaluate the expressionvalue
- the new value- 抛出:
EvaluationException
- if there is a problem during evaluation
setValue
void setValue(EvaluationContext context, @Nullable Object value) throws EvaluationException
Set this expression in the provided context to the value provided.- 参数:
context
- the context in which to set the value of the expressionvalue
- the new value- 抛出:
EvaluationException
- if there is a problem during evaluation
setValue
void setValue(EvaluationContext context, @Nullable Object rootObject, @Nullable Object value) throws EvaluationException
Set this expression in the provided context to the value provided. The supplied root object overrides any specified in the context.- 参数:
context
- the context in which to set the value of the expressionrootObject
- the root object against which to evaluate the expressionvalue
- the new value- 抛出:
EvaluationException
- if there is a problem during evaluation