// JDK 1.3.1_04: returns valid Method objects from these methods.
// JDK 1.4.2_05: returns null from these methods.
//
for (int i = 0; i < descriptors.length; i++) {
if (descriptors[i] instanceof IndexedPropertyDescriptor) {
IndexedPropertyDescriptor descriptor = (IndexedPropertyDescriptor)descriptors[i];
String propName = descriptor.getName().substring(0, 1).toUpperCase() +
descriptor.getName().substring(1);
if (descriptor.getReadMethod() == null) {
String methodName = descriptor.getIndexedReadMethod() != null
? descriptor.getIndexedReadMethod().getName()
: "get" + propName;
Method readMethod = MethodUtils.getMatchingAccessibleMethod(beanClass,
methodName,
EMPTY_CLASS_PARAMETERS);
if (readMethod != null) {
try {
descriptor.setReadMethod(readMethod);
} catch(Exception e) {
log.error("Error setting indexed property read method", e);
}
}
}
if (descriptor.getWriteMethod() == null) {
String methodName = descriptor.getIndexedWriteMethod() != null
? descriptor.getIndexedWriteMethod().getName()
: "set" + propName;
Method writeMethod = MethodUtils.getMatchingAccessibleMethod(beanClass,
methodName,
LIST_CLASS_PARAMETER);
if (writeMethod == null) {
Method[] methods = beanClass.getMethods();
for (int j = 0; j < methods.length; j++) {
if (methods[j].getName().equals(methodName)) {
Class[] parameterTypes = methods[j].getParameterTypes();
if (parameterTypes.length == 1 &&
List.class.isAssignableFrom(parameterTypes[0])) {
writeMethod = methods[j];
break;
}
}
}
}
if (writeMethod != null) {
try {
descriptor.setWriteMethod(writeMethod);
} catch(Exception e) {
log.error("Error setting indexed property write method", e);
}
}
}