1 19 20 25 26 package org.netbeans.modules.j2ee.sun.share.config.ui; 27 28 import java.beans.*; 29 import java.lang.reflect.*; 30 import java.util.*; 31 32 33 38 public class DefaultBeanInfo extends SimpleBeanInfo { 39 40 final Class cls; 41 42 43 public DefaultBeanInfo(Class cls) { 44 this.cls = cls; 45 } 46 47 public BeanDescriptor getBeanDescriptor() { 48 return new BeanDescriptor(cls); 49 } 50 51 public PropertyDescriptor[] getPropertyDescriptors() { 52 Method[] methods = cls.getDeclaredMethods(); 53 Collection c = new Vector(); 54 for(int i = 0; i < methods.length; i++) { 55 try { 56 String method = methods[i].getName(); 57 if(method.startsWith("get") && methods[i].getParameterTypes().length == 0) { StringBuffer name = (new StringBuffer (method.substring(3))); 59 name.setCharAt(0,Character.toLowerCase(method.charAt(3))); 60 String propertyName = name.toString(); 61 PropertyDescriptor pd; 62 if(methods[i].getReturnType().isArray()) 63 pd = new IndexedPropertyDescriptor(propertyName,cls); 64 else pd = new PropertyDescriptor(propertyName,cls); 65 c.add(pd); 69 } 70 } catch (Exception e) { 71 } 72 } 73 PropertyDescriptor[] ret = new PropertyDescriptor[c.size()]; 74 c.toArray(ret); 75 return ret; 76 } 77 } 78 | Popular Tags |