com.mortbay.Util
Interface Converter
- All Known Implementing Classes:
- ConverterBase
- public interface Converter
Interface for converting classes
Notes
A good check for implementors of this class as a first line is:
if (toConvert.getClass().equals(convertTo)) return toConvert;
- Version:
- 1.0 Thu Jun 8 2000
- Author:
- Matthew Watson (mattw)
- See Also:
ConverterSet
Method Summary |
java.lang.Object |
convert(java.lang.Object toConvert,
java.lang.Class convertTo,
Converter context)
Try to convert a value. |
java.lang.Object |
unsafeConvert(java.lang.Object toConvert,
java.lang.Class convertTo,
Converter context)
Try to convert a value and report errors if conversion not totally
successful. |
convert
public java.lang.Object convert(java.lang.Object toConvert,
java.lang.Class convertTo,
Converter context)
- Try to convert a value.
- 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
unsafeConvert
public java.lang.Object unsafeConvert(java.lang.Object toConvert,
java.lang.Class convertTo,
Converter context)
throws ConvertFail
- Try to convert a value and report errors if conversion not totally
successful.
- 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.
- Throws:
- ConvertFail - If the conversion is not totally successful.