Class AbstractArrayConverter
- java.lang.Object
-
- org.apache.commons.beanutils.converters.AbstractArrayConverter
-
- All Implemented Interfaces:
Converter
- Direct Known Subclasses:
BooleanArrayConverter
,ByteArrayConverter
,CharacterArrayConverter
,DoubleArrayConverter
,FloatArrayConverter
,IntegerArrayConverter
,LongArrayConverter
,ShortArrayConverter
,StringArrayConverter
@Deprecated public abstract class AbstractArrayConverter extends java.lang.Object implements Converter
Deprecated.Replaced by the newArrayConverter
implementationConvenience base class for converters that translate the String representation of an array into a corresponding array of primitives object. This class encapsulates the functionality required to parse the String into a list of String elements that can later be individually converted to the appropriate primitive type.
The input syntax accepted by the
parseElements()
method is designed to be compatible with the syntax used to initialize arrays in a Java source program, except that only String literal values are supported. For maximum flexibility, the surrounding '{' and '}' characters are optional, and individual elements may be separated by any combination of whitespace and comma characters.- Since:
- 1.4
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Object
defaultValue
Deprecated.The default value specified to our Constructor, if any.static java.lang.Object
NO_DEFAULT
Deprecated.This is a special reference that can be passed as the "default object" to the constructor to indicate that no default is desired.protected static java.lang.String[]
strings
Deprecated.Model object for string arrays.protected boolean
useDefault
Deprecated.Should we return the default value on conversion errors?
-
Constructor Summary
Constructors Constructor Description AbstractArrayConverter()
Deprecated.Create aConverter
that will throw aConversionException
if a conversion error occurs.AbstractArrayConverter(java.lang.Object defaultValue)
Deprecated.Create aConverter
that will return the specified default value if a conversion error occurs.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract java.lang.Object
convert(java.lang.Class type, java.lang.Object value)
Deprecated.Convert the specified input object into an output object of the specified type.protected java.util.List<java.lang.String>
parseElements(java.lang.String svalue)
Deprecated.Parse an incoming String of the form similar to an array initializer in the Java language into aList
individual Strings for each element, according to the following rules.
-
-
-
Field Detail
-
NO_DEFAULT
public static final java.lang.Object NO_DEFAULT
Deprecated.This is a special reference that can be passed as the "default object" to the constructor to indicate that no default is desired. Note that the value 'null' cannot be used for this purpose, as the caller may want a null to be returned as the default.- Since:
- 1.8.0
-
strings
protected static java.lang.String[] strings
Deprecated.Model object for string arrays.
-
defaultValue
protected java.lang.Object defaultValue
Deprecated.The default value specified to our Constructor, if any.
-
useDefault
protected boolean useDefault
Deprecated.Should we return the default value on conversion errors?
-
-
Constructor Detail
-
AbstractArrayConverter
public AbstractArrayConverter()
Deprecated.Create aConverter
that will throw aConversionException
if a conversion error occurs.
-
AbstractArrayConverter
public AbstractArrayConverter(java.lang.Object defaultValue)
Deprecated.Create aConverter
that will return the specified default value if a conversion error occurs.- Parameters:
defaultValue
- The default value to be returned- Since:
- 1.8.0
-
-
Method Detail
-
convert
public abstract java.lang.Object convert(java.lang.Class type, java.lang.Object value)
Deprecated.Convert the specified input object into an output object of the specified type. This method must be implemented by a concrete subclass.- Specified by:
convert
in interfaceConverter
- Parameters:
type
- Data type to which this value should be convertedvalue
- The input value to be converted- Returns:
- The converted value
- Throws:
ConversionException
- if conversion cannot be performed successfully
-
parseElements
protected java.util.List<java.lang.String> parseElements(java.lang.String svalue)
Deprecated.Parse an incoming String of the form similar to an array initializer in the Java language into a
List
individual Strings for each element, according to the following rules.- The string is expected to be a comma-separated list of values.
- The string may optionally have matching '{' and '}' delimiters around the list.
- Whitespace before and after each element is stripped.
- Elements in the list may be delimited by single or double quotes. Within a quoted elements, the normal Java escape sequences are valid.
- Parameters:
svalue
- String value to be parsed- Returns:
- The parsed list of String values
- Throws:
ConversionException
- if the syntax ofsvalue
is not syntactically validjava.lang.NullPointerException
- ifsvalue
isnull
-
-