in src/main/java/org/apache/commons/beanutils2/locale/LocaleBeanUtilsBean.java [158:191]
protected Object convert(final Class<?> type, final int index, final Object value, final String pattern) {
if (LOG.isTraceEnabled()) {
LOG.trace("Converting value '" + value + "' to type:" + type);
}
Object newValue = null;
if (type.isArray() && index < 0) { // Scalar value into array
if (value instanceof String) {
final String[] values = new String[1];
values[0] = (String) value;
newValue = getLocaleConvertUtils().convert(values, type, pattern);
} else if (value instanceof String[]) {
newValue = getLocaleConvertUtils().convert((String[]) value, type, pattern);
} else {
newValue = value;
}
} else if (type.isArray()) { // Indexed value into array
if (value instanceof String) {
newValue = getLocaleConvertUtils().convert((String) value, type.getComponentType(), pattern);
} else if (value instanceof String[]) {
newValue = getLocaleConvertUtils().convert(((String[]) value)[0], type.getComponentType(), pattern);
} else {
newValue = value;
}
} else if (value instanceof String) {
newValue = getLocaleConvertUtils().convert((String) value, type, pattern);
} else if (value instanceof String[]) {
newValue = getLocaleConvertUtils().convert(((String[]) value)[0], type, pattern);
} else {
newValue = value;
}
return newValue;
}