org.springframework.web.util
Class ExpressionEvaluationUtils


public abstract class ExpressionEvaluationUtils

Convenience methods for easy access to the JSP Expression Language evaluator of Jakarta's JSTL implementation.

The evaluation methods check if the value contains "${" before invoking the EL evaluator, treating the value as "normal" expression (i.e. conventional String) else.

Note: The evaluation methods do not have a runtime dependency on Jakarta's JSTL implementation, as long as they don't receive actual EL expressions.

Author:
Juergen Hoeller, Alef Arendsen
Since: 11.07.2003

Method Summary
 static Objectevaluate(String attrName, String attrValue, Class resultClass, PageContext pageContext)
          Evaluate the given expression to an Object, be it EL or a conventional String.
 static booleanevaluateBoolean(String attrName, String attrValue, PageContext pageContext)
          Evaluate the given expression to a boolean, be it EL or a conventional String.
 static intevaluateInteger(String attrName, String attrValue, PageContext pageContext)
          Evaluate the given expression to an integer, be it EL or a conventional String.
 static StringevaluateString(String attrName, String attrValue, PageContext pageContext)
          Evaluate the given expression to a String, be it EL or a conventional String.
 static booleanisExpressionLanguage(String value)
          Check if the given expression value is an EL expression.

Method Detail

evaluate

public static Object evaluate(String attrName, String attrValue, Class resultClass, PageContext pageContext)
throws JspException
Evaluate the given expression to an Object, be it EL or a conventional String.
Parameters:
attrName - name of the attribute (typically a JSP tag attribute)
attrValue - value of the attribute
resultClass - class that the result should have (String, Integer, Boolean)
pageContext - current JSP PageContext
Returns: the result of the evaluation
Throws:
JspException - in case of parsing errors

evaluateBoolean

public static boolean evaluateBoolean(String attrName, String attrValue, PageContext pageContext)
throws JspException
Evaluate the given expression to a boolean, be it EL or a conventional String.
Parameters:
attrName - name of the attribute (typically a JSP tag attribute)
attrValue - value of the attribute
pageContext - current JSP PageContext
Returns: the result of the evaluation
Throws:
JspException - in case of parsing errors

evaluateInteger

public static int evaluateInteger(String attrName, String attrValue, PageContext pageContext)
throws JspException
Evaluate the given expression to an integer, be it EL or a conventional String.
Parameters:
attrName - name of the attribute (typically a JSP tag attribute)
attrValue - value of the attribute
pageContext - current JSP PageContext
Returns: the result of the evaluation
Throws:
JspException - in case of parsing errors

evaluateString

public static String evaluateString(String attrName, String attrValue, PageContext pageContext)
throws JspException
Evaluate the given expression to a String, be it EL or a conventional String.
Parameters:
attrName - name of the attribute (typically a JSP tag attribute)
attrValue - value of the attribute
pageContext - current JSP PageContext
Returns: the result of the evaluation
Throws:
JspException - in case of parsing errors

isExpressionLanguage

public static boolean isExpressionLanguage(String value)
Check if the given expression value is an EL expression.
Parameters:
value - the expression to check
Returns: true if the expression is an EL expression, false otherwise