类 ExpressionUtils
- java.lang.Object
- org.springframework.expression.common.ExpressionUtils
public abstract class ExpressionUtils extends Object
Common utility functions that may be used by any Expression Language provider.- 从以下版本开始:
- 3.0
- 作者:
- Andy Clement, Juergen Hoeller
构造器概要
构造器 构造器 说明 ExpressionUtils()
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 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.static boolean
toBoolean(TypeConverter typeConverter, TypedValue typedValue)
Attempt to convert a typed value to a boolean using the supplied type converter.static byte
toByte(TypeConverter typeConverter, TypedValue typedValue)
Attempt to convert a typed value to a byte using the supplied type converter.static char
toChar(TypeConverter typeConverter, TypedValue typedValue)
Attempt to convert a typed value to a char using the supplied type converter.static double
toDouble(TypeConverter typeConverter, TypedValue typedValue)
Attempt to convert a typed value to a double using the supplied type converter.static float
toFloat(TypeConverter typeConverter, TypedValue typedValue)
Attempt to convert a typed value to a float using the supplied type converter.static int
toInt(TypeConverter typeConverter, TypedValue typedValue)
Attempt to convert a typed value to an int using the supplied type converter.static long
toLong(TypeConverter typeConverter, TypedValue typedValue)
Attempt to convert a typed value to a long using the supplied type converter.static short
toShort(TypeConverter typeConverter, TypedValue typedValue)
Attempt to convert a typed value to a short using the supplied type converter.
构造器详细资料
ExpressionUtils
public ExpressionUtils()
方法详细资料
convertTypedValue
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.- 参数:
context
- the evaluation context that may define a type convertertypedValue
- the value to convert and a type descriptor describing ittargetType
- the type to attempt conversion to- 返回:
- the converted value
- 抛出:
EvaluationException
- if there is a problem during conversion or conversion of the value to the specified type is not supported
toInt
public static int toInt(TypeConverter typeConverter, TypedValue typedValue)
Attempt to convert a typed value to an int using the supplied type converter.
toBoolean
public static boolean toBoolean(TypeConverter typeConverter, TypedValue typedValue)
Attempt to convert a typed value to a boolean using the supplied type converter.
toDouble
public static double toDouble(TypeConverter typeConverter, TypedValue typedValue)
Attempt to convert a typed value to a double using the supplied type converter.
toLong
public static long toLong(TypeConverter typeConverter, TypedValue typedValue)
Attempt to convert a typed value to a long using the supplied type converter.
toChar
public static char toChar(TypeConverter typeConverter, TypedValue typedValue)
Attempt to convert a typed value to a char using the supplied type converter.
toShort
public static short toShort(TypeConverter typeConverter, TypedValue typedValue)
Attempt to convert a typed value to a short using the supplied type converter.
toFloat
public static float toFloat(TypeConverter typeConverter, TypedValue typedValue)
Attempt to convert a typed value to a float using the supplied type converter.
toByte
public static byte toByte(TypeConverter typeConverter, TypedValue typedValue)
Attempt to convert a typed value to a byte using the supplied type converter.