|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.opensymphony.xwork2.conversion.impl.DefaultTypeConverter
public class DefaultTypeConverter
Default type conversion. Converts among numeric types and also strings. Contains the basic type mapping code from OGNL.
Field Summary |
---|
Fields inherited from interface com.opensymphony.xwork2.conversion.TypeConverter |
---|
NO_CONVERSION_POSSIBLE, TYPE_CONVERTER_CONTEXT_KEY |
Constructor Summary | |
---|---|
DefaultTypeConverter()
|
Method Summary | |
---|---|
static BigDecimal |
bigDecValue(Object value)
Evaluates the given object as a BigDecimal. |
static BigInteger |
bigIntValue(Object value)
Evaluates the given object as a BigInteger. |
static boolean |
booleanValue(Object value)
Evaluates the given object as a boolean: if it is a Boolean object, it's easy; if it's a Number or a Character, returns true for non-zero objects; and otherwise returns true for non-null objects. |
Object |
convertValue(Map<String,Object> context,
Object value,
Class toType)
|
Object |
convertValue(Map<String,Object> context,
Object target,
Member member,
String propertyName,
Object value,
Class toType)
Converts the given value to a given type. |
Object |
convertValue(Object value,
Class toType)
Returns the value converted numerically to the given class type This method also detects when arrays are being converted and converts the components of one array to the type of the other. |
static double |
doubleValue(Object value)
Evaluates the given object as a double-precision floating-point number. |
Enum<?> |
enumValue(Class toClass,
Object o)
|
TypeConverter |
getTypeConverter(Map<String,Object> context)
|
static long |
longValue(Object value)
Evaluates the given object as a long integer. |
static String |
stringValue(Object value)
Evaluates the given object as a String. |
static String |
stringValue(Object value,
boolean trim)
Evaluates the given object as a String and trims it if the trim flag is true. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultTypeConverter()
Method Detail |
---|
public Object convertValue(Map<String,Object> context, Object value, Class toType)
public Object convertValue(Map<String,Object> context, Object target, Member member, String propertyName, Object value, Class toType)
TypeConverter
convertValue
in interface TypeConverter
context
- context under which the conversion is being donetarget
- target object in which the property is being setmember
- member (Constructor, Method or Field) being setpropertyName
- property name being setvalue
- value to be convertedtoType
- type to which value is converted
public TypeConverter getTypeConverter(Map<String,Object> context)
public Object convertValue(Object value, Class toType)
value
- an object to be converted to the given typetoType
- class type to be converted to
public static boolean booleanValue(Object value)
value
- an object to interpret as a boolean
public Enum<?> enumValue(Class toClass, Object o)
public static long longValue(Object value) throws NumberFormatException
value
- an object to interpret as a long integer
NumberFormatException
- if the given object can't be understood as a long integerpublic static double doubleValue(Object value) throws NumberFormatException
value
- an object to interpret as a double
NumberFormatException
- if the given object can't be understood as a doublepublic static BigInteger bigIntValue(Object value) throws NumberFormatException
value
- an object to interpret as a BigInteger
NumberFormatException
- if the given object can't be understood as a BigIntegerpublic static BigDecimal bigDecValue(Object value) throws NumberFormatException
value
- an object to interpret as a BigDecimal
NumberFormatException
- if the given object can't be understood as a BigDecimalpublic static String stringValue(Object value, boolean trim)
value
- an object to interpret as a String
public static String stringValue(Object value)
value
- an object to interpret as a String
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |