org.springframework.web.util
Class ExpressionEvaluationUtils

java.lang.Object
  extended by org.springframework.web.util.ExpressionEvaluationUtils

public abstract class ExpressionEvaluationUtils
extends Object

Convenience methods for easy access to the JSP 2.0 ExpressionEvaluator or the ExpressionEvaluatorManager of Jakarta's JSTL implementation.

Automatically detects JSP 2.0 or Jakarta JSTL; falls back to throwing an exception on actual EL expressions if none of the two is available.

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

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

Since:
11.07.2003
Author:
Juergen Hoeller, Alef Arendsen
See Also:
ExpressionEvaluator, ExpressionEvaluatorManager

Constructor Summary
ExpressionEvaluationUtils()
           
 
Method Summary
static Object evaluate(String attrName, String attrValue, Class resultClass, PageContext pageContext)
          Evaluate the given expression to an Object, be it EL or a conventional String.
static Object evaluate(String attrName, String attrValue, PageContext pageContext)
          Evaluate the given expression to an Object, be it EL or a conventional String.
static boolean evaluateBoolean(String attrName, String attrValue, PageContext pageContext)
          Evaluate the given expression to a boolean, be it EL or a conventional String.
static int evaluateInteger(String attrName, String attrValue, PageContext pageContext)
          Evaluate the given expression to an integer, be it EL or a conventional String.
static String evaluateString(String attrName, String attrValue, PageContext pageContext)
          Evaluate the given expression to a String, be it EL or a conventional String.
static boolean isExpressionLanguage(String value)
          Check if the given expression value is an EL expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionEvaluationUtils

public ExpressionEvaluationUtils()
Method Detail

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

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

evaluate

public static Object evaluate(String attrName,
                              String attrValue,
                              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
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

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

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


Copyright (c) 2002-2006 The Spring Framework Project.