|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
TypeConverters are used to convert objects from one type to another, convert
strings to objects and to convert from objects and strings to arrays of objects.
The way that this is setup is that a TypeConverter implementation is
registered with the TypeConverterManager. The manager can then be queried
for a particular TypeConveter (see TypeConveterManager
for more information about retrieval). Next, the
TypeConverter can be used for conversions using one of four methods described
below. Any given TypeConverter may be used to convert to many different types
because of the way that the TypeConverterManager searches for TypeConverters.
Because of this flexibility when converting, the TypeConverter must be
told what type to convert to. This is the reason for the second convertTo
parameter on all of the convert methods.
Method Summary | |
Object |
convert(Object value,
Class convertTo)
Converts the given object to the given type. |
Object |
convertArray(Object[] values,
Class convertTo)
Converts the given array to an object. |
Object[] |
convertArrayToArray(Object[] values,
Class convertTo)
Converts the array to an array of the given type. |
Object |
convertString(String value,
Class convertTo)
Converts the given String to the given type. |
Object[] |
convertStringToArray(String value,
String delimiter,
Class convertTo)
Converts the String to an array of objects of the given type (normally by using a StringTokenizer and converting each token to the correct type). |
Object[] |
convertToArray(Object value,
Class convertTo)
Converts the given object to an array of objects of the given type. |
Method Detail |
public Object convert(Object value, Class convertTo) throws TypeConversionException
value
- The value to convertconvertTo
- The type to convert the value toTypeConversionException
- If there was a problem converting the
given value to the given typepublic Object convertString(String value, Class convertTo) throws TypeConversionException
value
- The String value to convertconvertTo
- The type to convert the value toTypeConversionException
- If there was a problem converting the
given value to the given typepublic Object convertArray(Object[] values, Class convertTo) throws TypeConversionException
values
- The array to convert to an objectconvertTo
- The type to convert the values toTypeConversionException
- If there was a problem converting the given
array to an Obejctpublic Object[] convertArrayToArray(Object[] values, Class convertTo) throws TypeConversionException
values
- The array to convert to an arrayconvertTo
- Either the array type of the component type for the array
being converted toTypeConversionException
- If there was a problem converting the given
array to an arraypublic Object[] convertToArray(Object value, Class convertTo) throws TypeConversionException
value
- The value to convert to an arrayconvertTo
- The componenet type of the array being converted toTypeConversionException
- If there was a problem converting the
given value to the given typepublic Object[] convertStringToArray(String value, String delimiter, Class convertTo) throws TypeConversionException
value
- The String value to convert to an arrayconvertTo
- The componenet type of the array being converted toTypeConversionException
- If there was a problem converting the
given value to the given type
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |