1 3 package jodd.introspector; 4 5 import java.lang.reflect.Method ; 6 import java.util.ArrayList ; 7 8 11 class Properties { 12 13 Methods getters = new Methods(); 14 String [] getterNames = new String [0]; 15 Methods setters = new Methods(); 16 String [] setterNames = new String [0]; 17 18 ArrayList getterNameList; 19 ArrayList setterNameList; 20 21 void addMethod(String name, Method method) { 22 if (name.charAt(0) == '-') { 23 name = name.substring(1); 24 getters.addMethod(name, method); 25 if (getterNameList == null) { 26 getterNameList = new ArrayList (); 27 } 28 getterNameList.add(name); 29 } else if (name.charAt(0) == '+') { 30 name = name.substring(1); 31 setters.addMethod(name, method); 32 if (setterNameList == null) { 33 setterNameList = new ArrayList (); 34 } 35 setterNameList.add(name); 36 } 37 } 38 39 void lock() { 40 if (getterNameList != null) { 41 getterNames = new String [getterNameList.size()]; 42 for (int i = 0; i < getterNameList.size(); i++) { 43 getterNames[i] = (String ) getterNameList.get(i); 44 } 45 getterNameList = null; 46 } 47 if (setterNameList != null) { 48 setterNames = new String [setterNameList.size()]; 49 for (int i = 0; i < setterNameList.size(); i++) { 50 setterNames[i] = (String ) setterNameList.get(i); 51 } 52 setterNameList = null; 53 } 54 getters.lock(); 55 setters.lock(); 56 } 57 58 public String [] getAllBeanGetterNames() { 59 return getterNames; 60 } 61 public String [] getAllBeanSetterNames() { 62 return setterNames; 63 } 64 } | Popular Tags |