{@link Converter} implementaion that handles conversionto and from
Boolean objects. {@link Converter} implementaion thathandles conversion to and from
java.lang.Boolean objects.
Can be configured to either return a default value or throw a ConversionException
if a conversion error occurs.
By default any object whose string representation is one of the values {"yes", "y", "true", "on", "1"} is converted to Boolean.TRUE, and string representations {"no", "n", "false", "off", "0"} are converted to Boolean.FALSE. The recognised true/false strings can be changed by:
String[] trueStrings = {"oui", "o", "1"}; String[] falseStrings = {"non", "n", "0"}; Converter bc = new BooleanConverter(trueStrings, falseStrings); ConvertUtils.register(bc, Boolean.class); ConvertUtils.register(bc, Boolean.TYPE);
In addition, it is recommended that the BooleanArrayConverter also be modified to recognise the same set of values:
Converter bac = new BooleanArrayConverter(bc, BooleanArrayConverter.NO_DEFAULT); ConvertUtils.register(bac, bac.MODEL);
Case is ignored when converting values to true or false.
@author Craig R. McClanahan
@version $Revision: 801644 $ $Date: 2009-08-06 14:38:56 +0100 (Thu, 06 Aug 2009) $
@since 1.3