com.mortbay.Util
Class ConverterSet
java.lang.Object
|
+--com.mortbay.Util.ConverterSet
- public class ConverterSet
- extends java.lang.Object
- implements Converter
Class to handle converting of types from one to another.
Other Converters can be registered with this ConverterSet and it will try
them all in turn until it finds one that works.
This class also provides a set of "standard" converters that handle the
primitive types, that can be installed by calling
registerPrimitiveConverters().
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
ConverterSet
public ConverterSet()
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
register
public void register(Converter converter)
registerPrimitiveConverters
public void registerPrimitiveConverters()
- register the standard converters for the primitive types