// Deal with a null value
if (value == null) {
if (useDefault) {
return (defaultValue);
} else {
throw new ConversionException("No value specified");
}
}
// Deal with the no-conversion-needed case
if (model.getClass() == value.getClass()) {
return (value);
}
// Deal with the input value as an int array
if (ints.getClass() == value.getClass())
{
int[] values = (int[]) value;
String[] results = new String[values.length];
for (int i = 0; i < values.length; i++)
{
results[i] = Integer.toString(values[i]);
}
return (results);
}
// Parse the input value as a String into elements
// and convert to the appropriate type
try {
List list = parseElements(value.toString());
String results[] = new String[list.size()];
for (int i = 0; i < results.length; i++) {
results[i] = (String) list.get(i);
}
return (results);
} catch (Exception e) {
if (useDefault) {
return (defaultValue);
} else {
throw new ConversionException(value.toString(), e);
}
}
}