Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.beanutils.converters
Class StringArrayConverter

    java.lang.Object
      org.apache.commons.beanutils.converters.AbstractArrayConverter
          org.apache.commons.beanutils.converters.StringArrayConverter

All Implemented Interfaces:
  Converter

Deprecated. Replaced by the new `ArrayConverter` implementation

    public final class StringArrayConverter

extends AbstractArrayConverter

Standard `Converter` implementation that converts an incoming String into an array of String objects. On a conversion failure, returns a specified default value or throws a `ConversionException` depending on how this instance is constructed.

There is also some special handling where the input is of type int[]. See method convert for more details.

Since:
  1.4
Version:
  $Revision: 556229 $ $Date: 2007-07-14 07:11:19 +0100 (Sat, 14 Jul 2007) $
Author:
  Craig R. McClanahan

Field Summary

Fields inherited from class org.apache.commons.beanutils.converters.AbstractArrayConverter
`defaultValue, NO_DEFAULT, strings, useDefault`

Constructor Summary
`StringArrayConverter()` Deprecated. Create a `Converter` that will throw a `ConversionException` if a conversion error occurs.
`StringArrayConverter(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 the specified type.

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`

Constructor Detail

### StringArrayConverter

    public StringArrayConverter()

  Deprecated.
  Create a `Converter` that will throw a `ConversionException` if a conversion error occurs.

### StringArrayConverter

    public StringArrayConverter(Object defaultValue)

  Deprecated.
  Create a `Converter` that will return the specified default value if a conversion error occurs.

  Parameters:
    `defaultValue` - The default value to be returned

Method Detail

### convert

    public Object convert(Class type,
                          Object value)

  Deprecated.
  Convert the specified input object into an output object of the specified type.

  If the value is already of type String[] then it is simply returned unaltered.

  If the value is of type int[], then a String[] is returned where each element in the string array is the result of calling Integer.toString on the corresponding element of the int array. This was added as a result of bugzilla request #18297 though there is not complete agreement that this feature should have been added.

  In all other cases, this method calls toString on the input object, then assumes the result is a comma-separated list of values. The values are split apart into the individual items and returned as the elements of an array. See class AbstractArrayConverter for the exact input formats supported.

  Specified by:
    `convert` in interface `Converter`
  Specified by:
    `convert` in class `AbstractArrayConverter`
  Parameters:
    `type` - is the data type to which this value should be converted. It is expected to be the class for type String[] (though this parameter is actually ignored by this method).
    `value` - is the input value to be converted. If null then the default value is returned or an exception thrown if no default value exists.
  Returns:
    the converted value
  Throws:
    `ConversionException` - if conversion cannot be performed successfully, or the input is null and there is no default value set for this object.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2009 The Apache Software Foundation. All Rights Reserved.