Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.puppycrawl.tools.checkstyle.api
Class StrArrayConverter  view StrArrayConverter download StrArrayConverter.java

java.lang.Object
  extended byorg.apache.commons.beanutils.converters.AbstractArrayConverter
      extended bycom.puppycrawl.tools.checkstyle.api.StrArrayConverter
All Implemented Interfaces:
org.apache.commons.beanutils.Converter

final class StrArrayConverter
extends org.apache.commons.beanutils.converters.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, "_" :(


Field Summary
private static java.lang.String[] sModel
          Model object for type comparisons.
 
Fields inherited from class org.apache.commons.beanutils.converters.AbstractArrayConverter
defaultValue, strings, useDefault
 
Constructor Summary
StrArrayConverter()
          Creates a new StrArrayConverter object.
StrArrayConverter(java.lang.Object aDefaultValue)
          Create a onverter that will return the specified default value if a conversion error occurs.
 
Method Summary
 java.lang.Object convert(java.lang.Class aType, java.lang.Object aValue)
          Convert the specified input object into an output object of the specified type.
protected  java.util.List parseElements(java.lang.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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sModel

private static java.lang.String[] sModel

Model object for type comparisons.

Constructor Detail

StrArrayConverter

public StrArrayConverter()
Creates a new StrArrayConverter object.


StrArrayConverter

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

Method Detail

convert

public java.lang.Object convert(java.lang.Class aType,
                                java.lang.Object aValue)
                         throws org.apache.commons.beanutils.ConversionException
Convert the specified input object into an output object of the specified type.


parseElements

protected java.util.List parseElements(java.lang.String aValue)
                                throws java.lang.NullPointerException

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 must have matching '{' and '}' delimiters around a comma-delimited list of values.
  • Whitespace before and after each element is stripped.
  • If an element is itself delimited by matching single or double quotes, the usual rules for interpreting a quoted String apply.