* The java.beans.Introspector does not process the interfaces hierarchy chain, this one does. *
* @author Alejandro Abdelnur
*
*/
public class BeanIntrospector {
private static final Map _introspected = new HashMap();
public static synchronized PropertyDescriptor[] getPropertyDescriptors(Class klass) throws IntrospectionException {
PropertyDescriptor[] descriptors = (PropertyDescriptor[]) _introspected.get(klass);
if (descriptors==null) {
descriptors = getPDs(klass);
_introspected.put(klass,descriptors);
}
return descriptors;
}
private static PropertyDescriptor[] getPDs(Class klass) throws IntrospectionException {
Method[] methods = klass.getMethods();
Map getters = getPDs(methods,false);
Map setters = getPDs(methods,true);
List pds = merge(getters,setters);
PropertyDescriptor[] array = new PropertyDescriptor[pds.size()];
pds.toArray(array);
return array;
}
private static final String SETTER = "set";
private static final String GETTER = "get";
private static final String BOOLEAN_GETTER = "is";
private static Map getPDs(Method[] methods,boolean setters) throws IntrospectionException {
Map pds = new HashMap();
for (int i=0;i