ArrayConverter
implementation@Deprecated public final class BooleanArrayConverter extends AbstractArrayConverter
Standard Converter
implementation that converts an incoming
String into a primitive array of boolean. On a conversion failure, returns
a specified default value or throws a ConversionException
depending
on how this instance is constructed.
By default, the values to be converted are expected to be those recognised by a default instance of BooleanConverter. A customised BooleanConverter can be provided in order to recognise alternative values as true/false.
Modifier and Type | Field and Description |
---|---|
protected BooleanConverter |
booleanConverter
Deprecated.
This object is used to perform the conversion of individual strings
into Boolean/boolean values.
|
static Class |
MODEL
Deprecated.
Type which this class converts its input to.
|
defaultValue, NO_DEFAULT, strings, useDefault
Constructor and Description |
---|
BooleanArrayConverter()
Deprecated.
Create a
Converter that will throw
a ConversionException if a conversion error occurs. |
BooleanArrayConverter(BooleanConverter converter,
Object defaultValue)
Deprecated.
Create a
Converter that will return
the specified default value if a conversion error occurs. |
BooleanArrayConverter(Object defaultValue)
Deprecated.
Create a
Converter that will return
the specified default value if a conversion error occurs. |
Modifier and Type | Method and Description |
---|---|
Object |
convert(Class type,
Object value)
Deprecated.
Convert the specified input object into an output object of type
array-of-boolean.
|
parseElements
public static final Class MODEL
protected final BooleanConverter booleanConverter
public BooleanArrayConverter()
Converter
that will throw
a ConversionException
if a conversion error occurs.
Conversion of strings to boolean values will be done via a default instance of class BooleanConverter.
public BooleanArrayConverter(Object defaultValue)
Converter
that will return
the specified default value if a conversion error occurs.
Conversion of strings to boolean values will be done via a default instance of class BooleanConverter.
defaultValue
- The default value to be returnedpublic BooleanArrayConverter(BooleanConverter converter, Object defaultValue)
Converter
that will return
the specified default value if a conversion error occurs.
Conversion of strings to boolean values will be done via the specified converter.
converter
- is the converter object that will be used to
convert each input string-value into a boolean.defaultValue
- is the default value to be returned by method
convert if conversion fails; null is a valid default value. See the
documentation for method "convert" for more information.
The value BooleanArrayConverter.NO_DEFAULT may be passed here to
specify that an exception should be thrown on conversion failure.public Object convert(Class type, Object value)
If the input value is null, then the default value specified in the constructor is returned. If no such value was provided, then a ConversionException is thrown instead.
If the input value is of type String[] then the returned array shall be of the same size as this array, with a true or false value in each array element depending on the result of applying method BooleanConverter.convert to each string.
For all other types of value, the object's toString method is
expected to return a string containing a comma-separated list of
values, eg "true, false, true". See the documentation for
AbstractArrayConverter.parseElements(java.lang.String)
for more information on
the exact formats supported.
If the result of value.toString() cannot be split into separate words, then the default value is also returned (or an exception thrown).
If any of the elements in the value array (or the elements resulting from splitting up value.toString) are not recognised by the BooleanConverter associated with this object, then what happens depends on whether that BooleanConverter has a default value or not: if it does, then that unrecognised element is converted into the BooleanConverter's default value. If the BooleanConverter does not have a default value, then the default value for this object is returned as the complete conversion result (not just for the element), or an exception is thrown if this object has no default value defined.
convert
in interface Converter
convert
in class AbstractArrayConverter
type
- is the type to which this value should be converted. In the
case of this BooleanArrayConverter class, this value is ignored.value
- is the input value to be converted.ConversionException
- if conversion cannot be performed
successfully and the constructor was not provided with a default
value to return on conversion failure.NullPointerException
- if value is an array, and any of the
array elements are null.Copyright © 2000–2014 The Apache Software Foundation. All rights reserved.