T - data type handled by this converterpublic abstract class ObjectConverter<T>
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ObjectConverter.MappedEnumConverter<T>
Object converter for pseudo-enum types backed by a map.
|
| Constructor and Description |
|---|
ObjectConverter() |
| Modifier and Type | Method and Description |
|---|---|
static <V> void |
addConverter(java.lang.Class<V> type,
ObjectConverter<V> converter)
Add converter for a data type.
|
abstract T |
convertValue(java.lang.String value,
java.lang.Class<? extends T> datatype)
Translate an untyped (string) value to a typed value.
|
static <V> V |
getValue(java.lang.Object value,
java.lang.Class<V> datatype)
Converts an object to the given datatype by casting if possible, and if not
by narrowing from
String using the registered object converters. |
static <V> V |
getValue(java.lang.String value,
java.lang.Class<V> datatype)
Translate an untyped (string) value to a typed value.
|
public static <V> void addConverter(java.lang.Class<V> type,
ObjectConverter<V> converter)
type - data typeconverter - converterpublic static <V> V getValue(java.lang.Object value,
java.lang.Class<V> datatype)
throws ParseException
String using the registered object converters.V - the type of value to return.value - the value to convert.datatype - the datatype to convert to.ParseException - if narrowing was not possible.public static <V> V getValue(java.lang.String value,
java.lang.Class<V> datatype)
throws ParseException
V - data typevalue - valuedatatype - class of value typeParseException - if value cannot be parsed according to typepublic abstract T convertValue(java.lang.String value, java.lang.Class<? extends T> datatype) throws ParseException
value - value to convert.T.ParseException - if value cannot be parsed according to type