1 19 20 package org.netbeans.modules.schema2beans; 21 22 import java.beans.*; 23 import java.util.*; 24 import java.lang.reflect.*; 25 26 public class DDBeanInfo extends SimpleBeanInfo { 27 28 private static final String BEANINFO = "BeanInfo"; 30 private PropertyDescriptor[] properties = null; 31 32 private boolean propertiesInited = false; 33 34 private void initProperties() { 35 ArrayList al = new ArrayList(); 36 String classname = null; 37 BeanInfo bi; 38 39 try { 40 classname = this.getClass().getName(); 41 if (!classname.endsWith(BEANINFO)) { 42 return; 43 } 44 classname = classname.substring(0,(classname.length() - 45 BEANINFO.length())); 46 bi = Introspector.getBeanInfo(Class.forName(classname)); 47 } catch (ClassNotFoundException e) { 48 System.err.println("Class name = " + classname); return; 50 } catch (IntrospectionException e) { 51 Thread.dumpStack(); 52 return; 53 } 54 55 PropertyDescriptor[] pd = bi.getPropertyDescriptors(); 56 Method m = null; 57 for (int i=0;i<pd.length; i++) { 58 Class c = null; 59 if (pd[i] instanceof IndexedPropertyDescriptor) { 60 IndexedPropertyDescriptor ipd = 61 (IndexedPropertyDescriptor)pd[i]; 62 c = ipd.getIndexedPropertyType(); 63 } else { 64 c = pd[i].getPropertyType(); 65 } 66 if (c != null) { 74 if (BaseBean.class.isAssignableFrom(c) || 75 (c.getName().startsWith("java.lang.") 76 && !c.getName().equals("java.lang.Class")) || (c.getName().indexOf(".") < 0)) { 79 al.add(pd[i]); 80 } 81 } 82 } 83 properties = (PropertyDescriptor[])al.toArray(new PropertyDescriptor[al.size()]); 84 85 } 86 87 88 100 public PropertyDescriptor[] getPropertyDescriptors() { 101 if (!propertiesInited) { 102 propertiesInited = true; 104 initProperties(); 105 } 106 return properties; 107 } 108 109 } 110 | Popular Tags |