com.puppycrawl.tools.checkstyle.api

Class StrArrayConverter

final class StrArrayConverter extends AbstractArrayConverter

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

Hacked from http://cvs.apache.org/viewcvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/converters/StringArrayConverter.java because that implementation fails to convert array of tokens with elements containing an underscore, "_" :(

Author: Rick Giles

Constructor Summary
StrArrayConverter()
Creates a new StrArrayConverter object.
StrArrayConverter(Object aDefaultValue)
Create a onverter that will return the specified default value if a conversion error occurs.
Method Summary
Objectconvert(Class aType, Object aValue)
Convert the specified input object into an output object of the specified type.
protected ListparseElements(String aValue)

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.

Constructor Detail

StrArrayConverter

public StrArrayConverter()
Creates a new StrArrayConverter object.

StrArrayConverter

public StrArrayConverter(Object aDefaultValue)
Create a onverter that will return the specified default value if a conversion error occurs.

Parameters: aDefaultValue The default value to be returned

Method Detail

convert

public Object convert(Class aType, Object aValue)
Convert the specified input object into an output object of the specified type.

Parameters: aType Data type to which this value should be converted aValue The input value to be converted

Returns: the converted object

Throws: ConversionException if conversion cannot be performed successfully

parseElements

protected List parseElements(String aValue)

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.

Parameters: aValue String value to be parsed

Returns: the list of Strings parsed from the array

Throws: NullPointerException if svalue is null