1 21 22 package org.apache.commons.validator; 23 24 import java.io.Serializable ; 25 import java.util.Collections ; 26 import java.util.HashMap ; 27 import java.util.Iterator ; 28 import java.util.Map ; 29 30 35 public class FormSet implements Serializable { 36 37 41 private boolean processed = false; 42 43 46 private String language = null; 47 48 51 private String country = null; 52 53 56 private String variant = null; 57 58 62 private Map forms = new HashMap (); 63 64 68 private Map constants = new HashMap (); 69 70 74 public boolean isProcessed() { 75 return processed; 76 } 77 78 81 public String getLanguage() { 82 return language; 83 } 84 85 88 public void setLanguage(String language) { 89 this.language = language; 90 } 91 92 95 public String getCountry() { 96 return country; 97 } 98 99 102 public void setCountry(String country) { 103 this.country = country; 104 } 105 106 109 public String getVariant() { 110 return variant; 111 } 112 113 116 public void setVariant(String variant) { 117 this.variant = variant; 118 } 119 120 123 public void addConstant(String name, String value) { 124 this.constants.put(name, value); 125 } 126 127 130 public void addForm(Form f) { 131 forms.put(f.getName(), f); 132 } 133 134 137 public Form getForm(String formName) { 138 return (Form) this.forms.get(formName); 139 } 140 141 145 public Map getForms() { 146 return Collections.unmodifiableMap(forms); 147 } 148 149 152 synchronized void process(Map globalConstants) { 153 for (Iterator i = forms.values().iterator(); i.hasNext();) { 154 Form f = (Form) i.next(); 155 f.process(globalConstants, constants, forms); 156 } 157 158 processed = true; 159 } 160 161 164 public String toString() { 165 StringBuffer results = new StringBuffer (); 166 167 results.append("FormSet: language="); 168 results.append(language); 169 results.append(" country="); 170 results.append(country); 171 results.append(" variant="); 172 results.append(variant); 173 results.append("\n"); 174 175 for (Iterator i = getForms().values().iterator(); i.hasNext();) { 176 results.append(" "); 177 results.append(i.next()); 178 results.append("\n"); 179 } 180 181 return results.toString(); 182 } 183 184 } | Popular Tags |