null
, ���׳���Ĭ��ֵ��ConvertFailedException
. Boolean
��, ֱ�ӷ���. Number
����, �Ҳ�Ϊ0
, ��true
, ����false
. 0
, ��true
, ����false
. ConvertFailedException
. "false", "null", "nul", "nil", "off", "no", "n"
��Ϊfalse
. "true", "on", "yes", "y"
��Ϊtrue
. ConvertFailedException
. Converter
����. Boolean
. Conversion rules: null
value is returned as null
true
; and opposite values for false
.Standard {@link Converter} implementation that converts an incomingString into a java.lang.Boolean
object, optionally using a default value or throwing a {@link ConversionException} if a conversionerror occurs.
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"true", "1", "on", "false", "0", "off"
转换为 {@linkplain Boolean}类型对象
@author earthangry@gmail.com
@date 2010-10-3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|