| java.lang.Object |
| ↳ |
com.google.gdata.wireformats.ObjectConverter<T> |
Known Direct Subclasses
|
Class Overview
Converts values from strings to typed values (objects).
Summary
| Nested Classes |
|
class |
ObjectConverter.MappedEnumConverter<T> |
Object converter for pseudo-enum types backed by a map. |
| Public Methods |
|
static
<V>
void
|
addConverter(Class<V> type, ObjectConverter<V> converter)
Add converter for a data type.
|
|
abstract
T
|
convertValue(String value, Class<? extends T> datatype)
Translate an untyped (string) value to a typed value.
|
|
static
<V>
V
|
getValue(String value, Class<V> datatype)
Translate an untyped (string) value to a typed value.
|
|
static
<V>
V
|
getValue(Object value, 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.
|
|
[Expand]
Inherited Methods |
From class
java.lang.Object
|
Object
|
clone()
|
|
boolean
|
equals(Object arg0)
|
|
void
|
finalize()
|
|
final
Class<?>
|
getClass()
|
|
int
|
hashCode()
|
|
final
void
|
notify()
|
|
final
void
|
notifyAll()
|
|
String
|
toString()
|
|
final
void
|
wait()
|
|
final
void
|
wait(long arg0, int arg1)
|
|
final
void
|
wait(long arg0)
|
|
Fields
private
static
final
ConcurrentMap<Class<?>, ObjectConverter<?>>
CONVERTERS
Map from data type to value convert. This is used for types that don't have
a string-arg constructor or need special handling.
Public Constructors
public
ObjectConverter
()
Public Methods
public
static
void
addConverter
(Class<V> type, ObjectConverter<V> converter)
Add converter for a data type.
Parameters
| type
| Data type |
| converter
| Converter
|
public
abstract
T
convertValue
(String value, Class<? extends T> datatype)
Translate an untyped (string) value to a typed value.
Parameters
| value
| Value to convert. |
| datatype
| |
Returns
- value converted to type
T.
public
static
V
getValue
(String value, Class<V> datatype)
Translate an untyped (string) value to a typed value.
Parameters
| value
| Value |
| datatype
| Class of value type |
public
static
V
getValue
(Object value, 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.
Parameters
| value
| The value to convert. |
| datatype
| The datatype to convert to. |
Returns
- the original value if it could be cast to the required type, or
a narrowed version of the value if narrowing was possible.