ArrayConverter
implementation@Deprecated public abstract class AbstractArrayConverter extends Object implements Converter
Convenience 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.
Modifier and Type | Field and Description |
---|---|
protected Object |
defaultValue
Deprecated.
The default value specified to our Constructor, if any.
|
static 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 String[] |
strings
Deprecated.
Model object for string arrays.
|
protected boolean |
useDefault
Deprecated.
Should we return the default value on conversion errors?
|
Constructor and Description |
---|
AbstractArrayConverter()
Deprecated.
Create a
Converter that will throw a ConversionException
if a conversion error occurs. |
AbstractArrayConverter(Object defaultValue)
Deprecated.
Create a
Converter that will return the specified default value
if a conversion error occurs. |
Modifier and Type | Method and Description |
---|---|
abstract Object |
convert(Class type,
Object value)
Deprecated.
Convert the specified input object into an output object of the
specified type.
|
protected List |
parseElements(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. |
public static final Object NO_DEFAULT
protected Object defaultValue
protected boolean useDefault
public AbstractArrayConverter()
Converter
that will throw a ConversionException
if a conversion error occurs.public AbstractArrayConverter(Object defaultValue)
Converter
that will return the specified default value
if a conversion error occurs.defaultValue
- The default value to be returnedpublic abstract Object convert(Class type, Object value)
convert
in interface Converter
type
- Data type to which this value should be convertedvalue
- The input value to be convertedConversionException
- if conversion cannot be performed
successfullyprotected List parseElements(String svalue)
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.
svalue
- String value to be parsedConversionException
- if the syntax of svalue
is not syntactically validNullPointerException
- if svalue
is null
Copyright © 2000–2019 The Apache Software Foundation. All rights reserved.