com.mortbay.Util
Class DictionaryConverter
java.lang.Object
|
+--com.mortbay.Util.DictionaryConverter
- public class DictionaryConverter
- extends java.lang.Object
- implements Converter
Class to convert Dictionary's to complex object types.
This class tries to convert a Dictionary (Hashtable or Properties etc) to
a complex Object. This is done by iterating over all the public settable
bean Properties and fields of an Object and trying to set them from values
in the Dictionary. Types in the dictionary will be converted using the
context as passed to this Converter, so the user should make sure that
this Converter is part of a ConverterSet capable of handling the requires
conversions.
Method Summary |
java.lang.Object |
convert(java.lang.Object toConvert,
java.lang.Class convertTo,
Converter context)
Try to convert a value. |
static void |
fillObject(java.lang.Object toFill,
java.util.Dictionary from,
Converter converter)
|
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
DictionaryConverter
public DictionaryConverter()
convert
public java.lang.Object convert(java.lang.Object toConvert,
java.lang.Class convertTo,
Converter context)
- Description copied from interface: Converter
- Try to convert a value.
A good check for implementors of this class as a first line is:
if (toConvert.getClass().equals(convertTo)) return toConvert;
- Specified by:
- convert in interface Converter
- Tags copied from interface: Converter
- Parameters:
toConvert
- Value to convertconvertTo
- Type to convert tocontext
- The context within which the converter was called.
If Converters use other Converters, this is passed as
the outermost Converter so that recursive calls have
access to all available Converters. Converter
implementations should pass this if passed null.- Returns:
- The converted value, or null if not possible
fillObject
public static void fillObject(java.lang.Object toFill,
java.util.Dictionary from,
Converter converter)