org.apache.commons.beanutils.converters
Class BooleanArrayConverter

java.lang.Object
  extended by org.apache.commons.beanutils.converters.AbstractArrayConverter
      extended by org.apache.commons.beanutils.converters.BooleanArrayConverter
All Implemented Interfaces:
Converter

Deprecated. Replaced by the new ArrayConverter implementation

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.

Since:
1.4
Version:
$Revision: 690380 $ $Date: 2008-08-29 21:04:38 +0100 (Fri, 29 Aug 2008) $
Author:
Craig R. McClanahan

Field Summary
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.
 
Fields inherited from class org.apache.commons.beanutils.converters.AbstractArrayConverter
defaultValue, NO_DEFAULT, strings, useDefault
 
Constructor Summary
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.
 
Method Summary
 Object convert(Class type, Object value)
          Deprecated. Convert the specified input object into an output object of type array-of-boolean.
 
Methods inherited from class org.apache.commons.beanutils.converters.AbstractArrayConverter
parseElements
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODEL

public static final Class MODEL
Deprecated. 
Type which this class converts its input to. This value can be used as a parameter to the ConvertUtils.register method.

Since:
1.8.0

booleanConverter

protected final BooleanConverter booleanConverter
Deprecated. 
This object is used to perform the conversion of individual strings into Boolean/boolean values.

Constructor Detail

BooleanArrayConverter

public BooleanArrayConverter()
Deprecated. 
Create a 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.


BooleanArrayConverter

public BooleanArrayConverter(Object defaultValue)
Deprecated. 
Create a 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.

Parameters:
defaultValue - The default value to be returned

BooleanArrayConverter

public BooleanArrayConverter(BooleanConverter converter,
                             Object defaultValue)
Deprecated. 
Create a 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.

Parameters:
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.
Method Detail

convert

public Object convert(Class type,
                      Object value)
Deprecated. 
Convert the specified input object into an output object of type array-of-boolean.

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.

Specified by:
convert in interface Converter
Specified by:
convert in class AbstractArrayConverter
Parameters:
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.
Returns:
an object of type boolean[], or the default value if there was any sort of error during conversion and the constructor was provided with a default value.
Throws:
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-2009 The Apache Software Foundation. All Rights Reserved.