public abstract class DefaultTypeConverter extends Object implements TypeConverter
Modifier and Type | Field and Description |
---|---|
protected static String |
MILLISECOND_FORMAT |
NO_CONVERSION_POSSIBLE, TYPE_CONVERTER_CONTEXT_KEY
Constructor and Description |
---|
DefaultTypeConverter() |
Modifier and Type | Method and Description |
---|---|
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) |
protected Locale |
getLocale(Map<String,Object> context) |
TypeConverter |
getTypeConverter(Map<String,Object> context) |
static long |
longValue(Object value)
Evaluates the given object as a long integer.
|
void |
setContainer(Container container) |
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.
|
protected static final String MILLISECOND_FORMAT
public void setContainer(Container container)
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 convertedpublic 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 topublic static boolean booleanValue(Object value)
value
- an object to interpret as a booleanpublic static long longValue(Object value)
value
- an object to interpret as a long integerpublic static double doubleValue(Object value)
value
- an object to interpret as a doublepublic static BigInteger bigIntValue(Object value)
value
- an object to interpret as a BigIntegerpublic static BigDecimal bigDecValue(Object value)
value
- an object to interpret as a BigDecimalpublic static String stringValue(Object value, boolean trim)
value
- an object to interpret as a Stringtrim
- trims the result if truepublic static String stringValue(Object value)
value
- an object to interpret as a StringCopyright © 2000–2020 Apache Software Foundation. All rights reserved.