|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.twelvemonkeys.util.convert.Converter
public abstract class Converter
The converter (singleton). Converts strings to objects and back. This is the entry point to the converter framework.
By default, converters forTime, 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)| Field Summary | |
|---|---|
protected Map<Class,PropertyConverter> |
converters
The converters Map |
protected static Converter |
sInstance
Our singleton instance |
| Constructor Summary | |
|---|---|
protected |
Converter()
Creates a Converter. |
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final Converter sInstance
protected final Map<Class,PropertyConverter> converters
| Constructor Detail |
|---|
protected Converter()
| Method Detail |
|---|
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 to
ConversionException - if the string cannot be converted for any
reason.
public abstract Object toObject(String pString,
Class pType,
String pFormat)
throws ConversionException
toObject in interface PropertyConverterpString - the string to convertpType - the type to convert topFormat - the (optional) conversion format
ConversionException - 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 PropertyConverterpObject - the object to convert.pFormat - the (optional) conversion format
ConversionException - if the object cannot be converted to a
string for any reason.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||