*
* @return a configured BeanUtilsBean
*/
private static BeanUtilsBean createBeanUtilsBean()
{
final ConvertUtilsBean cub = new ConvertUtilsBean();
// TODO: is there a smarter way to tell beanutils not to use defaults?
final boolean[] booleanArray = new boolean[0];
final byte[] byteArray = new byte[0];
final char[] charArray = new char[0];
final double[] doubleArray = new double[0];
final float[] floatArray = new float[0];
final int[] intArray = new int[0];
final long[] longArray = new long[0];
final short[] shortArray = new short[0];
cub.register(new BooleanConverter(), Boolean.TYPE);
cub.register(new BooleanConverter(), Boolean.class);
cub.register(
new BooleanArrayConverter(), booleanArray.getClass());
cub.register(new ByteConverter(), Byte.TYPE);
cub.register(new ByteConverter(), Byte.class);
cub.register(
new ByteArrayConverter(byteArray), byteArray.getClass());
cub.register(new CharacterConverter(), Character.TYPE);
cub.register(new CharacterConverter(), Character.class);
cub.register(
new CharacterArrayConverter(), charArray.getClass());
cub.register(new DoubleConverter(), Double.TYPE);
cub.register(new DoubleConverter(), Double.class);
cub.register(
new DoubleArrayConverter(doubleArray), doubleArray.getClass());
cub.register(new FloatConverter(), Float.TYPE);
cub.register(new FloatConverter(), Float.class);
cub.register(new FloatArrayConverter(), floatArray.getClass());
cub.register(new IntegerConverter(), Integer.TYPE);
cub.register(new IntegerConverter(), Integer.class);
cub.register(new IntegerArrayConverter(), intArray.getClass());
cub.register(new LongConverter(), Long.TYPE);
cub.register(new LongConverter(), Long.class);
cub.register(new LongArrayConverter(), longArray.getClass());
cub.register(new ShortConverter(), Short.TYPE);
cub.register(new ShortConverter(), Short.class);
cub.register(new ShortArrayConverter(), shortArray.getClass());
// TODO: investigate:
// StringArrayConverter doesn't properly convert an array of tokens with
// elements containing an underscore, "_".
// Hacked a replacement class :(
// cub.register(new StringArrayConverter(),
// String[].class);
cub.register(new StrArrayConverter(), String[].class);
cub.register(new IntegerArrayConverter(), Integer[].class);
// BigDecimal, BigInteger, Class, Date, String, Time, TimeStamp
// do not use defaults in the default configuration of ConvertUtilsBean
return new BeanUtilsBean(cub, new PropertyUtilsBean());