public abstract class Converter extends Object implements PropertyConverter
Time
, Date
and Object
(the DefaultConverter
) are registered by this class' static
initializer. You might remove them using the
unregisterConverter
method.registerConverter(Class, PropertyConverter)
,
unregisterConverter(Class)
Modifier and Type | Field and Description |
---|---|
protected Map<Class,PropertyConverter> |
converters
The converters Map
|
protected static Converter |
sInstance
Our singleton instance
|
Modifier | Constructor and Description |
---|---|
protected |
Converter()
Creates a Converter.
|
Modifier and Type | Method and Description |
---|---|
static Converter |
getInstance()
Gets the Converter instance.
|
static void |
registerConverter(Class<?> pType,
PropertyConverter pConverter)
Registers a converter for a given type.
|
Object |
toObject(String pString,
Class pType)
Converts the string to an object of the given type.
|
abstract Object |
toObject(String pString,
Class pType,
String pFormat)
Converts the string to an object of the given type, parsing after the
given format.
|
String |
toString(Object pObject)
Converts the object to a string, using
object.toString() |
abstract String |
toString(Object pObject,
String pFormat)
Converts the object to a string, using
object.toString() |
static void |
unregisterConverter(Class<?> pType)
Un-registers a converter for a given type.
|
protected static final Converter sInstance
protected final Map<Class,PropertyConverter> converters
public static Converter getInstance()
public static void registerConverter(Class<?> pType, PropertyConverter pConverter)
Time
, Date
and Object
(the DefaultConverter
) are registered by this class' static
initializer. You might remove them using the
unregisterConverter
method.pType
- the (super) type to register a converter forpConverter
- the converterunregisterConverter(Class)
public static void unregisterConverter(Class<?> pType)
pType
- the (super) type to remove converter forregisterConverter(Class,PropertyConverter)
public Object toObject(String pString, Class pType) throws ConversionException
pString
- the string to convertpType
- the type to convert toConversionException
- if the string cannot be converted for any
reason.public abstract Object toObject(String pString, Class pType, String pFormat) throws ConversionException
toObject
in interface PropertyConverter
pString
- the string to convertpType
- the type to convert topFormat
- the (optional) conversion formatConversionException
- if the string cannot be converted for any
reason.public String toString(Object pObject) throws ConversionException
object.toString()
pObject
- the object to convert.ConversionException
- if the object cannot be converted to a
string for any reason.public abstract String toString(Object pObject, String pFormat) throws ConversionException
object.toString()
toString
in interface PropertyConverter
pObject
- the object to convert.pFormat
- the (optional) conversion formatConversionException
- if the object cannot be converted to a
string for any reason.Copyright © 2017. All rights reserved.