}
if (value.getClass().isArray()) {
int length = Array.getLength(value);
Object convertedValues = Array.newInstance(componentType, length);
ConvertManager manager = chain.getConvertManager();
for (int i = 0; i < length; i++) {
Array.set(convertedValues, i, manager.asType(componentType, Array.get(value, i)));
}
return convertedValues;
}
if (value instanceof Collection) {
Collection values = (Collection) value;
Object convertedValues = Array.newInstance(componentType, values.size());
ConvertManager manager = chain.getConvertManager();
Iterator iterator = values.iterator();
for (int i = 0; iterator.hasNext(); i++) {
Array.set(convertedValues, i, manager.asType(componentType, iterator.next()));
}
return convertedValues;
}
Iterator iterator = null;
if (value instanceof Iterator) {
iterator = (Iterator) value;
} else if (value instanceof Enumeration) {
iterator = new EnumerationIterator((Enumeration) value);
}
if (iterator != null) {
List convertedValueList = new ArrayList();
ConvertManager manager = chain.getConvertManager();
while (iterator.hasNext()) {
convertedValueList.add(manager.asType(componentType, iterator.next()));
}
int length = convertedValueList.size();
Object convertedValues = Array.newInstance(componentType, length);