| java.lang.Object org.apache.commons.beanutils.converters.AbstractArrayConverter
All known Subclasses: org.apache.commons.beanutils.converters.FloatArrayConverter, org.apache.commons.beanutils.converters.ShortArrayConverter, org.apache.commons.beanutils.converters.BooleanArrayConverter, org.apache.commons.beanutils.converters.IntegerArrayConverter, org.apache.commons.beanutils.converters.LongArrayConverter, org.apache.commons.beanutils.converters.CharacterArrayConverter, org.apache.commons.beanutils.converters.DoubleArrayConverter, org.apache.commons.beanutils.converters.ByteArrayConverter, org.apache.commons.beanutils.converters.StringArrayConverter,
AbstractArrayConverter | abstract public class AbstractArrayConverter implements Converter(Code) | | 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.
author: Craig R. McClanahan version: $Revision: 557808 $ $Date: 2007-07-20 00:05:03 +0100 (Fri, 20 Jul 2007) $ since: 1.4ArrayConverter |
Field Summary | |
final public static Object | NO_DEFAULT This is a special reference that can be passed as the "default object"
to the constructor to indicate that no default is desired. | protected Object | defaultValue The default value specified to our Constructor, if any. | protected static String[] | strings | protected boolean | useDefault |
Method Summary | |
abstract public Object | convert(Class type, Object value) Convert the specified input object into an output object of the
specified type. | protected 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.
- 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.
|
NO_DEFAULT | final public static Object NO_DEFAULT(Code) | | 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.
|
defaultValue | protected Object defaultValue(Code) | | The default value specified to our Constructor, if any.
|
strings | protected static String[] strings(Code) | | Model object for string arrays.
|
useDefault | protected boolean useDefault(Code) | | Should we return the default value on conversion errors?
|
AbstractArrayConverter | public AbstractArrayConverter(Object defaultValue)(Code) | | Create a
Converter that will return the specified default value
if a conversion error occurs.
Parameters: defaultValue - The default value to be returned |
convert | abstract public Object convert(Class type, Object value)(Code) | | Convert the specified input object into an output object of the
specified type. This method must be implemented by a concrete
subclass.
Parameters: type - Data type to which this value should be converted Parameters: value - The input value to be converted The converted value exception: ConversionException - if conversion cannot be performedsuccessfully |
parseElements | protected List parseElements(String svalue)(Code) | | 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 The parsed list of String values exception: ConversionException - if the syntax of svalue is not syntactically valid exception: NullPointerException - if svalue is null |
|
|