1 package net.sourceforge.formview; 2 3 import java.util.ArrayList ; 4 import java.util.Iterator ; 5 import java.util.List ; 6 7 import org.apache.commons.collections.FastHashMap; 8 9 22 public class State { 23 24 private String name; 25 private String behaviour; 26 29 protected FastHashMap hFields = null; 30 protected List lFields = null; 31 32 public String getBehaviour() { 33 return behaviour; 34 } 35 public void setBehaviour(String behaviour) { 36 this.behaviour = behaviour; 37 } 38 public String getName() { 39 return name; 40 } 41 public void setName(String name) { 42 this.name = name; 43 } 44 47 public void addField(FieldView f, Class updatedByClass, String updatedByMethodName) { 48 if (hFields == null) 49 hFields = new FastHashMap(); 50 if (lFields == null) 51 lFields = new ArrayList (); 52 f.setUpdatedByClass(updatedByClass); 53 f.setUpdatedByMethodName(updatedByMethodName); 54 this.lFields.add(f); 55 this.hFields.put(f.getProperty(), f); 56 } 57 58 public void addField(FieldView f, Class updatedByClass) { 59 addField(f, updatedByClass, ""); 60 } 61 62 public void addField(FieldView f) { 63 addField(f, FormView.class); 64 } 65 66 public FieldView getField(String property) { 67 if (hFields != null) { 68 return (FieldView)hFields.get(property); 69 } 70 return null; 71 } 72 73 public List getFields() { 74 return lFields; 75 } 76 77 public Object clone() { 78 State stateCloned = new State(); 79 stateCloned.setBehaviour(this.behaviour); 80 stateCloned.setName(this.name); 81 if (lFields != null) { 83 for (Iterator iter = lFields.iterator(); iter.hasNext();) { 84 FieldView field = (FieldView) iter.next(); 85 stateCloned.addField((FieldView)field.clone()); 86 87 } 88 } 89 return stateCloned; 90 91 } 92 } 93 | Popular Tags |