Top Description Constructors Methods
org.springframework.expression.common

public abstract Class ExpressionUtils

extends Object
Class Inheritance
Imports
org.springframework.core.convert.TypeDescriptor, org.springframework.expression.EvaluationContext, .EvaluationException, .TypeConverter, .TypedValue, org.springframework.lang.Nullable, org.springframework.util.ClassUtils

Common utility functions that may be used by any Expression Language provider.
Authors
Andy Clement, Juergen Hoeller
Since
3.0

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static <T> T

Returns:

the converted value
convertTypedValue
(EvaluationContext
the evaluation context that may define a type converter
context
,
TypedValue
the value to convert and a type descriptor describing it
typedValue
,
Class<T>
the type to attempt conversion to
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.

private static <T> T
convertValue(TypeConverter typeConverter, TypedValue typedValue, Class<T> targetType)

public static boolean
toBoolean(TypeConverter typeConverter, TypedValue typedValue)

Attempt to convert a typed value to a boolean using the supplied type converter.

public static byte
toByte(TypeConverter typeConverter, TypedValue typedValue)

Attempt to convert a typed value to a byte using the supplied type converter.

public static char
toChar(TypeConverter typeConverter, TypedValue typedValue)

Attempt to convert a typed value to a char using the supplied type converter.

public static double
toDouble(TypeConverter typeConverter, TypedValue typedValue)

Attempt to convert a typed value to a double using the supplied type converter.

public static float
toFloat(TypeConverter typeConverter, TypedValue typedValue)

Attempt to convert a typed value to a float using the supplied type converter.

public static int
toInt(TypeConverter typeConverter, TypedValue typedValue)

Attempt to convert a typed value to an int using the supplied type converter.

public static long
toLong(TypeConverter typeConverter, TypedValue typedValue)

Attempt to convert a typed value to a long using the supplied type converter.

public static short
toShort(TypeConverter typeConverter, TypedValue typedValue)

Attempt to convert a typed value to a short using the supplied type converter.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ExpressionUtilsback to summary
public ExpressionUtils()

Method Detail

convertTypedValueback to summary
public static <T> T convertTypedValue(EvaluationContext context, TypedValue typedValue, 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:EvaluationContext

the evaluation context that may define a type converter

typedValue:TypedValue

the value to convert and a type descriptor describing it

targetType:Class<T>

the type to attempt conversion to

Returns:T

the converted value

Annotations
@SuppressWarnings:unchecked
@Nullable
Exceptions
EvaluationException:
if there is a problem during conversion or conversion of the value to the specified type is not supported
convertValueback to summary
private static <T> T convertValue(TypeConverter typeConverter, TypedValue typedValue, Class<T> targetType)
Annotations
@SuppressWarnings:unchecked
toBooleanback to summary
public static boolean toBoolean(TypeConverter typeConverter, TypedValue typedValue)

Attempt to convert a typed value to a boolean using the supplied type converter.

toByteback to summary
public static byte toByte(TypeConverter typeConverter, TypedValue typedValue)

Attempt to convert a typed value to a byte using the supplied type converter.

toCharback to summary
public static char toChar(TypeConverter typeConverter, TypedValue typedValue)

Attempt to convert a typed value to a char using the supplied type converter.

toDoubleback to summary
public static double toDouble(TypeConverter typeConverter, TypedValue typedValue)

Attempt to convert a typed value to a double using the supplied type converter.

toFloatback to summary
public static float toFloat(TypeConverter typeConverter, TypedValue typedValue)

Attempt to convert a typed value to a float using the supplied type converter.

toIntback to summary
public static int toInt(TypeConverter typeConverter, TypedValue typedValue)

Attempt to convert a typed value to an int using the supplied type converter.

toLongback to summary
public static long toLong(TypeConverter typeConverter, TypedValue typedValue)

Attempt to convert a typed value to a long using the supplied type converter.

toShortback to summary
public static short toShort(TypeConverter typeConverter, TypedValue typedValue)

Attempt to convert a typed value to a short using the supplied type converter.