Class ExpressionUtils
java.lang.Object
org.springframework.expression.common.ExpressionUtils
Common utility functions that may be used by any Expression Language provider.
- Since:
- 3.0
- Author:
- Andy Clement, Juergen Hoeller
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic <T> @Nullable TconvertTypedValue(@Nullable EvaluationContext context, TypedValue typedValue, @Nullable Class<T> targetType) Determines if there is a type converter available in the specified context and attempts to use it to convert the supplied value to the specified type.static booleantoBoolean(TypeConverter typeConverter, TypedValue typedValue) Attempt to convert a typed value to a boolean using the supplied type converter.static bytetoByte(TypeConverter typeConverter, TypedValue typedValue) Attempt to convert a typed value to a byte using the supplied type converter.static chartoChar(TypeConverter typeConverter, TypedValue typedValue) Attempt to convert a typed value to a char using the supplied type converter.static doubletoDouble(TypeConverter typeConverter, TypedValue typedValue) Attempt to convert a typed value to a double using the supplied type converter.static floattoFloat(TypeConverter typeConverter, TypedValue typedValue) Attempt to convert a typed value to a float using the supplied type converter.static inttoInt(TypeConverter typeConverter, TypedValue typedValue) Attempt to convert a typed value to an int using the supplied type converter.static longtoLong(TypeConverter typeConverter, TypedValue typedValue) Attempt to convert a typed value to a long using the supplied type converter.static shorttoShort(TypeConverter typeConverter, TypedValue typedValue) Attempt to convert a typed value to a short using the supplied type converter.
- 
Constructor Details- 
ExpressionUtilspublic ExpressionUtils()
 
- 
- 
Method Details- 
convertTypedValuepublic static <T> @Nullable T convertTypedValue(@Nullable EvaluationContext context, TypedValue typedValue, @Nullable Class<T> targetType) Determines if there is a type converter available in the specified context and attempts to use it to convert the supplied value to the specified type. Throws an exception if conversion is not possible.- Parameters:
- context- the evaluation context that may define a type converter
- typedValue- the value to convert and a type descriptor describing it
- targetType- the type to attempt conversion to
- Returns:
- the converted value
- Throws:
- EvaluationException- if there is a problem during conversion or conversion of the value to the specified type is not supported
 
- 
toIntAttempt to convert a typed value to an int using the supplied type converter.
- 
toBooleanAttempt to convert a typed value to a boolean using the supplied type converter.
- 
toDoubleAttempt to convert a typed value to a double using the supplied type converter.
- 
toLongAttempt to convert a typed value to a long using the supplied type converter.
- 
toCharAttempt to convert a typed value to a char using the supplied type converter.
- 
toShortAttempt to convert a typed value to a short using the supplied type converter.
- 
toFloatAttempt to convert a typed value to a float using the supplied type converter.
- 
toByteAttempt to convert a typed value to a byte using the supplied type converter.
 
-