Top Description Methods
org.springframework.expression

public Interface Expression

Known Direct Implementers
org.springframework.expression.common.CompositeStringExpression, org.springframework.expression.common.LiteralExpression, org.springframework.expression.spel.standard.SpelExpression
Imports
org.springframework.core.convert.TypeDescriptor, org.springframework.lang.Nullable

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.

Authors
Keith Donald, Andy Clement, Juergen Hoeller
Since
3.0

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the original expression string
getExpressionString
()

Return the original string used to create this expression (unmodified).

public Object

Returns:

the evaluation result
getValue
()

Evaluate this expression in the default standard context.

public <T> T

Returns:

the evaluation result
getValue
(Class<T>
the type the caller would like the result to be
desiredResultType
)

Evaluate this expression in the default context.

public Object

Returns:

the evaluation result
getValue
(Object
the root object against which to evaluate the expression
rootObject
)

Evaluate this expression against the specified root object.

public <T> T

Returns:

the evaluation result
getValue
(Object
the root object against which to evaluate the expression
rootObject
,
Class<T>
the type the caller would like the result to be
desiredResultType
)

Evaluate this expression in the default context against the specified root object.

public Object

Returns:

the evaluation result
getValue
(EvaluationContext
the context in which to evaluate the expression
context
)

Evaluate this expression in the provided context and return the result of evaluation.

public Object

Returns:

the evaluation result
getValue
(EvaluationContext
the context in which to evaluate the expression
context
,
Object
the root object against which to evaluate the expression
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.

public <T> T

Returns:

the evaluation result
getValue
(EvaluationContext
the context in which to evaluate the expression
context
,
Class<T>
the type the caller would like the result to be
desiredResultType
)

Evaluate this expression in the provided context which can resolve references to properties, methods, types, etc. The type of the evaluation result is expected to be of a particular type, and an exception will be thrown if it is not and cannot be converted to that type.

public <T> T

Returns:

the evaluation result
getValue
(EvaluationContext
the context in which to evaluate the expression
context
,
Object
the root object against which to evaluate the expression
rootObject
,
Class<T>
the type the caller would like the result to be
desiredResultType
)

Evaluate this expression in the provided context which can resolve references to properties, methods, types, etc. The type of the evaluation result is expected to be of a particular type, and an exception will be thrown if it is not and cannot be converted to that type.j

The supplied root object overrides any specified in the supplied context.

public Class<?>

Returns:

the most general type of value that can be set in this context
getValueType
()

Return the most general type that can be passed to the setValue(EvaluationContext, Object) method using the default context.

public Class<?>

Returns:

the most general type of value that can be set in this context
getValueType
(Object
the root object against which to evaluate the expression
rootObject
)

Return the most general type that can be passed to the setValue(Object, Object) method using the default context.

public Class<?>

Returns:

the most general type of value that can be set in this context
getValueType
(EvaluationContext
the context in which to evaluate the expression
context
)

Return the most general type that can be passed to the setValue(EvaluationContext, Object) method for the given context.

public Class<?>

Returns:

the most general type of value that can be set in this context
getValueType
(EvaluationContext
the context in which to evaluate the expression
context
,
Object
the root object against which to evaluate the expression
rootObject
)

Return the most general type that can be passed to the setValue(EvaluationContext, Object, Object) method for the given context.

public TypeDescriptor

Returns:

a type descriptor for values that can be set in this context
getValueTypeDescriptor
()

Return a descriptor for the most general type that can be passed to one of the setValue(...) methods using the default context.

public TypeDescriptor

Returns:

a type descriptor for values that can be set in this context
getValueTypeDescriptor
(Object
the root object against which to evaluate the expression
rootObject
)

Return a descriptor for the most general type that can be passed to the setValue(Object, Object) method using the default context.

public TypeDescriptor

Returns:

a type descriptor for values that can be set in this context
getValueTypeDescriptor
(EvaluationContext
the context in which to evaluate the expression
context
)

Return a descriptor for the most general type that can be passed to the setValue(EvaluationContext, Object) method for the given context.

public TypeDescriptor

Returns:

a type descriptor for values that can be set in this context
getValueTypeDescriptor
(EvaluationContext
the context in which to evaluate the expression
context
,
Object
the root object against which to evaluate the expression
rootObject
)

Return a descriptor for the most general type that can be passed to the setValue(EvaluationContext, Object, Object) method for the given context.

public boolean

Returns:

true if the expression is writable; false otherwise
isWritable
(Object
the root object against which to evaluate the expression
rootObject
)

Determine if this expression can be written to, i.e. setValue() can be called.

public boolean

Returns:

true if the expression is writable; false otherwise
isWritable
(EvaluationContext
the context in which the expression should be checked
context
)

Determine if this expression can be written to, i.e. setValue() can be called.

public boolean

Returns:

true if the expression is writable; false otherwise
isWritable
(EvaluationContext
the context in which the expression should be checked
context
,
Object
the root object against which to evaluate the expression
rootObject
)

Determine if this expression can be written to, i.e. setValue() can be called.

public void
setValue(Object
the root object against which to evaluate the expression
rootObject
,
Object
the new value
value
)

Set this expression in the provided context to the value provided.

public void
setValue(EvaluationContext
the context in which to set the value of the expression
context
,
Object
the new value
value
)

Set this expression in the provided context to the value provided.

public void
setValue(EvaluationContext
the context in which to set the value of the expression
context
,
Object
the root object against which to evaluate the expression
rootObject
,
Object
the new value
value
)

Set this expression in the provided context to the value provided.

Method Detail

getExpressionStringback to summary
public String getExpressionString()

Return the original string used to create this expression (unmodified).

Returns:String

the original expression string

getValueback to summary
public Object getValue() throws EvaluationException

Evaluate this expression in the default standard context.

Returns:Object

the evaluation result

Annotations
@Nullable
Exceptions
EvaluationException:
if there is a problem during evaluation
getValueback to summary
public <T> T getValue(Class<T> desiredResultType) throws EvaluationException

Evaluate this 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 thrown.

Parameters
desiredResultType:Class<T>

the type the caller would like the result to be

Returns:T

the evaluation result

Annotations
@Nullable
Exceptions
EvaluationException:
if there is a problem during evaluation
getValueback to summary
public Object getValue(Object rootObject) throws EvaluationException

Evaluate this expression against the specified root object.

Parameters
rootObject:Object

the root object against which to evaluate the expression

Returns:Object

the evaluation result

Annotations
@Nullable
Exceptions
EvaluationException:
if there is a problem during evaluation
getValueback to summary
public <T> T getValue(Object rootObject, Class<T> desiredResultType) throws EvaluationException

Evaluate this 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 thrown.

Parameters
rootObject:Object

the root object against which to evaluate the expression

desiredResultType:Class<T>

the type the caller would like the result to be

Returns:T

the evaluation result

Annotations
@Nullable
Exceptions
EvaluationException:
if there is a problem during evaluation
getValueback to summary
public Object getValue(EvaluationContext context) throws EvaluationException

Evaluate this expression in the provided context and return the result of evaluation.

Parameters
context:EvaluationContext

the context in which to evaluate the expression

Returns:Object

the evaluation result

Annotations
@Nullable
Exceptions
EvaluationException:
if there is a problem during evaluation
getValueback to summary
public Object getValue(EvaluationContext context, 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.

Parameters
context:EvaluationContext

the context in which to evaluate the expression

rootObject:Object

the root object against which to evaluate the expression

Returns:Object

the evaluation result

Annotations
@Nullable
Exceptions
EvaluationException:
if there is a problem during evaluation
getValueback to summary
public <T> T getValue(EvaluationContext context, Class<T> desiredResultType) throws EvaluationException

Evaluate this expression in the provided context which can resolve references to properties, methods, types, etc. The type of the evaluation result is expected to be of a particular type, and an exception will be thrown if it is not and cannot be converted to that type.

Parameters
context:EvaluationContext

the context in which to evaluate the expression

desiredResultType:Class<T>

the type the caller would like the result to be

Returns:T

the evaluation result

Annotations
@Nullable
Exceptions
EvaluationException:
if there is a problem during evaluation
getValueback to summary
public <T> T getValue(EvaluationContext context, Object rootObject, Class<T> desiredResultType) throws EvaluationException

Evaluate this expression in the provided context which can resolve references to properties, methods, types, etc. The type of the evaluation result is expected to be of a particular type, and an exception will be thrown if it is not and cannot be converted to that type.j

The supplied root object overrides any specified in the supplied context.

Parameters
context:EvaluationContext

the context in which to evaluate the expression

rootObject:Object

the root object against which to evaluate the expression

desiredResultType:Class<T>

the type the caller would like the result to be

Returns:T

the evaluation result

Annotations
@Nullable
Exceptions
EvaluationException:
if there is a problem during evaluation
getValueTypeback to summary
public Class<?> getValueType() throws EvaluationException

Return the most general type that can be passed to the setValue(EvaluationContext, Object) method using the default context.

Returns:Class<?>

the most general type of value that can be set in this context

Annotations
@Nullable
Exceptions
EvaluationException:
if there is a problem determining the type
getValueTypeback to summary
public Class<?> getValueType(Object rootObject) throws EvaluationException

Return the most general type that can be passed to the setValue(Object, Object) method using the default context.

Parameters
rootObject:Object

the root object against which to evaluate the expression

Returns:Class<?>

the most general type of value that can be set in this context

Annotations
@Nullable
Exceptions
EvaluationException:
if there is a problem determining the type
getValueTypeback to summary
public Class<?> getValueType(EvaluationContext context) throws EvaluationException

Return the most general type that can be passed to the setValue(EvaluationContext, Object) method for the given context.

Parameters
context:EvaluationContext

the context in which to evaluate the expression

Returns:Class<?>

the most general type of value that can be set in this context

Annotations
@Nullable
Exceptions
EvaluationException:
if there is a problem determining the type
getValueTypeback to summary
public Class<?> getValueType(EvaluationContext context, Object rootObject) throws EvaluationException

Return the most general type that can be passed to the setValue(EvaluationContext, Object, Object) method for the given context.

The supplied root object overrides any specified in the supplied context.

Parameters
context:EvaluationContext

the context in which to evaluate the expression

rootObject:Object

the root object against which to evaluate the expression

Returns:Class<?>

the most general type of value that can be set in this context

Annotations
@Nullable
Exceptions
EvaluationException:
if there is a problem determining the type
getValueTypeDescriptorback to summary
public TypeDescriptor getValueTypeDescriptor() throws EvaluationException

Return a descriptor for the most general type that can be passed to one of the setValue(...) methods using the default context.

Returns:TypeDescriptor

a type descriptor for values that can be set in this context

Annotations
@Nullable
Exceptions
EvaluationException:
if there is a problem determining the type
getValueTypeDescriptorback to summary
public TypeDescriptor getValueTypeDescriptor(Object rootObject) throws EvaluationException

Return a descriptor for the most general type that can be passed to the setValue(Object, Object) method using the default context.

Parameters
rootObject:Object

the root object against which to evaluate the expression

Returns:TypeDescriptor

a type descriptor for values that can be set in this context

Annotations
@Nullable
Exceptions
EvaluationException:
if there is a problem determining the type
getValueTypeDescriptorback to summary
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context) throws EvaluationException

Return a descriptor for the most general type that can be passed to the setValue(EvaluationContext, Object) method for the given context.

Parameters
context:EvaluationContext

the context in which to evaluate the expression

Returns:TypeDescriptor

a type descriptor for values that can be set in this context

Annotations
@Nullable
Exceptions
EvaluationException:
if there is a problem determining the type
getValueTypeDescriptorback to summary
public TypeDescriptor getValueTypeDescriptor(EvaluationContext context, Object rootObject) throws EvaluationException

Return a descriptor for the most general type that can be passed to the setValue(EvaluationContext, Object, Object) method for the given context.

The supplied root object overrides any specified in the supplied context.

Parameters
context:EvaluationContext

the context in which to evaluate the expression

rootObject:Object

the root object against which to evaluate the expression

Returns:TypeDescriptor

a type descriptor for values that can be set in this context

Annotations
@Nullable
Exceptions
EvaluationException:
if there is a problem determining the type
isWritableback to summary
public boolean isWritable(Object rootObject) throws EvaluationException

Determine if this expression can be written to, i.e. setValue() can be called.

Parameters
rootObject:Object

the root object against which to evaluate the expression

Returns:boolean

true if the expression is writable; false otherwise

Exceptions
EvaluationException:
if there is a problem determining if it is writable
isWritableback to summary
public boolean isWritable(EvaluationContext context) throws EvaluationException

Determine if this expression can be written to, i.e. setValue() can be called.

Parameters
context:EvaluationContext

the context in which the expression should be checked

Returns:boolean

true if the expression is writable; false otherwise

Exceptions
EvaluationException:
if there is a problem determining if it is writable
isWritableback to summary
public boolean isWritable(EvaluationContext context, Object rootObject) throws EvaluationException

Determine if this expression can be written to, i.e. setValue() can be called.

The supplied root object overrides any specified in the supplied context.

Parameters
context:EvaluationContext

the context in which the expression should be checked

rootObject:Object

the root object against which to evaluate the expression

Returns:boolean

true if the expression is writable; false otherwise

Exceptions
EvaluationException:
if there is a problem determining if it is writable
setValueback to summary
public void setValue(Object rootObject, Object value) throws EvaluationException

Set this expression in the provided context to the value provided.

Parameters
rootObject:Object

the root object against which to evaluate the expression

value:Object

the new value

Exceptions
EvaluationException:
if there is a problem during evaluation
setValueback to summary
public void setValue(EvaluationContext context, Object value) throws EvaluationException

Set this expression in the provided context to the value provided.

Parameters
context:EvaluationContext

the context in which to set the value of the expression

value:Object

the new value

Exceptions
EvaluationException:
if there is a problem during evaluation
setValueback to summary
public void setValue(EvaluationContext context, Object rootObject, Object value) throws EvaluationException

Set this expression in the provided context to the value provided.

The supplied root object overrides any specified in the supplied context.

Parameters
context:EvaluationContext

the context in which to set the value of the expression

rootObject:Object

the root object against which to evaluate the expression

value:Object

the new value

Exceptions
EvaluationException:
if there is a problem during evaluation