if (value instanceof String) {
Object result = null;
if (context == null)
result = ConvertUtils.convert((String) value,clazz);
else {
Converter contextConverter = null;
HashMap<Class,Converter> contextMap = contextMaps.get(context);
if (contextMap != null)
contextConverter = contextMap.get(clazz);
if (contextConverter != null) {
contextConverter.convert(clazz,value);
} else {
System.out.println("no context converter found ");
result = ConvertUtils.convert((String) value,clazz);
}
}
// if (result instanceof java.util.Date) { // dates need to be normalized
// result = new Date(DateTime.gmt((Date) result));
// }
if (result == null) {
throw new FieldParseException("Invalid type");
}
return result;
}
// Because of stupidity of beanutils which assumes type string, I implement this by hand
Converter converter = ConvertUtils.lookup(clazz);
if (converter == null) {
System.out.println("converter is null for class " + clazz + " instance " + instance.hashCode() + " resetting") ;
instance = new FieldConverter();
converter = ConvertUtils.lookup(String.class);
}
return converter.convert(clazz, value);
} catch (ConversionException conversionException) {
throw new FieldParseException(conversionException);
}
}