org.springframework.expression
Interface Expression

All Known Implementing Classes:
CompositeStringExpression, LiteralExpression, SpelExpression

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 independent of any language like OGNL or the Unified EL.

Since:
3.0
Author:
Keith Donald, Andy Clement

Method Summary
 String getExpressionString()
          Returns 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 standard context.
 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 - 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.
 Class getValueType()
          Returns the most general type that can be passed to the setValue(EvaluationContext, Object) method using the default context.
 Class getValueType(EvaluationContext context)
          Returns the most general type that can be passed to the setValue(EvaluationContext, Object) method for the given context.
 TypeDescriptor getValueTypeDescriptor()
          Returns the most general type that can be passed to the setValue(EvaluationContext, Object) method using the default context.
 TypeDescriptor getValueTypeDescriptor(EvaluationContext context)
          Returns the most general type that can be passed to the setValue(EvaluationContext, Object) method for the given context.
 boolean isWritable(EvaluationContext context)
          Determine if an expression can be written to, i.e.
 void setValue(EvaluationContext context, Object value)
          Set this expression in the provided context to the value provided.
 

Method Detail

getValue

Object getValue()
                throws EvaluationException
Evaluate this expression in the default standard context.

Returns:
the evaluation result
Throws:
EvaluationException - if there is a problem during evaluation

getValue

<T> T getValue(Class<T> desiredResultType)
           throws EvaluationException
Evaluate the expression in the default standard 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.

Parameters:
desiredResultType - the class the caller would like the result to be
Returns:
the evaluation result
Throws:
EvaluationException - if there is a problem during evaluation

getValue

Object getValue(EvaluationContext context)
                throws EvaluationException
Evaluate this expression in the provided context and return the result of evaluation.

Parameters:
context - the context in which to evaluate the expression
Returns:
the evaluation result
Throws:
EvaluationException - if there is a problem during evaluation

getValue

<T> T getValue(EvaluationContext context,
               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.

Parameters:
context - the context in which to evaluate the expression
desiredResultType - the class the caller would like the result to be
Returns:
the evaluation result
Throws:
EvaluationException - if there is a problem during evaluation

getValueType

Class getValueType()
                   throws EvaluationException
Returns the most general type that can be passed to the setValue(EvaluationContext, Object) method using the default context.

Returns:
the most general type of value that can be set on this context
Throws:
EvaluationException - if there is a problem determining the type

getValueType

Class getValueType(EvaluationContext context)
                   throws EvaluationException
Returns the most general type that can be passed to the setValue(EvaluationContext, Object) method for the given context.

Parameters:
context - the context in which to evaluate the expression
Returns:
the most general type of value that can be set on this context
Throws:
EvaluationException - if there is a problem determining the type

getValueTypeDescriptor

TypeDescriptor getValueTypeDescriptor()
                                      throws EvaluationException
Returns the most general type that can be passed to the setValue(EvaluationContext, Object) method using the default context.

Returns:
a type descriptor for the most general type of value that can be set on this context
Throws:
EvaluationException - if there is a problem determining the type

getValueTypeDescriptor

TypeDescriptor getValueTypeDescriptor(EvaluationContext context)
                                      throws EvaluationException
Returns the most general type that can be passed to the setValue(EvaluationContext, Object) method for the given context.

Parameters:
context - the context in which to evaluate the expression
Returns:
a type descriptor for the most general type of value that can be set on this context
Throws:
EvaluationException - if there is a problem determining the type

isWritable

boolean isWritable(EvaluationContext context)
                   throws EvaluationException
Determine if an expression can be written to, i.e. setValue() can be called.

Parameters:
context - the context in which the expression should be checked
Returns:
true if the expression is writable
Throws:
EvaluationException - if there is a problem determining if it is writable

setValue

void setValue(EvaluationContext context,
              Object value)
              throws EvaluationException
Set this expression in the provided context to the value provided.

Parameters:
context - the context in which to set the value of the expression
value - the new value
Throws:
EvaluationException - if there is a problem during evaluation

getExpressionString

String getExpressionString()
Returns the original string used to create this expression, unmodified.

Returns:
the original expression string