org.springframework.binding.expression.support
Class StaticExpression

java.lang.Object
  extended by org.springframework.binding.expression.support.StaticExpression
All Implemented Interfaces:
Expression

public final class StaticExpression
extends Object
implements Expression

A simple expression evaluator that just returns a fixed result on each evaluation.

Author:
Keith Donald

Constructor Summary
StaticExpression(Object value)
          Create a static evaluator for the given value.
 
Method Summary
 boolean equals(Object o)
           
 String getExpressionString()
          Returns the original string used to create this expression, unmodified.
 Object getValue(Object context)
          Evaluate this expression in the provided context and return the result of evaluation.
 Class getValueType(Object context)
          Returns the most general type that can be passed to the Expression.setValue(Object, Object) method for the given context.
 int hashCode()
           
 void setExpressionString(String expressionString)
          Sets the static expression string.
 void setValue(Object context, Object value)
          Set this expression in the provided context to the value provided.
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StaticExpression

public StaticExpression(Object value)
Create a static evaluator for the given value.

Parameters:
value - the value
Method Detail

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

getValue

public Object getValue(Object context)
                throws EvaluationException
Description copied from interface: Expression
Evaluate this expression in the provided context and return the result of evaluation.

Specified by:
getValue in interface Expression
Parameters:
context - the context to evaluate this expression in
Returns:
the evaluation result
Throws:
EvaluationException - an exception occurred during expression evaluation

setValue

public void setValue(Object context,
                     Object value)
              throws EvaluationException
Description copied from interface: Expression
Set this expression in the provided context to the value provided.

Specified by:
setValue in interface Expression
Parameters:
context - the context on which the new value should be set
value - the new value to set
Throws:
EvaluationException - an exception occurred during expression evaluation

getValueType

public Class getValueType(Object context)
Description copied from interface: Expression
Returns the most general type that can be passed to the Expression.setValue(Object, Object) method for the given context.

Specified by:
getValueType in interface Expression
Parameters:
context - the context to evaluate
Returns:
the most general type of value that can be set on this context, or null if the type information cannot be determined

getExpressionString

public String getExpressionString()
Description copied from interface: Expression
Returns the original string used to create this expression, unmodified.

Specified by:
getExpressionString in interface Expression
Returns:
the original expression string

setExpressionString

public void setExpressionString(String expressionString)
Sets the static expression string.

Parameters:
expressionString - the static expression string

toString

public String toString()
Overrides:
toString in class Object