1 16 17 package org.apache.struts.faces.util; 18 19 20 import java.util.Collection ; 21 import java.util.Locale ; 22 import java.util.Map ; 23 import java.util.Set ; 24 25 import org.apache.struts.util.MessageResources; 26 27 28 35 36 public class MessagesMap implements Map { 37 38 39 41 42 54 public MessagesMap(MessageResources messages, Locale locale) { 55 56 super(); 57 if (messages == null) { 58 throw new NullPointerException (); 59 } 60 this.messages = messages; 61 this.locale = locale; 62 63 } 64 65 66 68 69 73 private Locale locale = null; 74 75 76 80 private MessageResources messages = null; 81 82 83 85 86 89 public void clear() { 90 91 throw new UnsupportedOperationException (); 92 93 } 94 95 96 102 public boolean containsKey(Object key) { 103 104 if (key == null) { 105 return (false); 106 } else { 107 return (messages.isPresent(locale, key.toString())); 108 } 109 110 } 111 112 113 118 public boolean containsValue(Object value) { 119 120 throw new UnsupportedOperationException (); 121 122 } 123 124 125 128 public Set entrySet() { 129 130 throw new UnsupportedOperationException (); 131 132 } 133 134 135 142 public boolean equals(Object o) { 143 144 if (!(o instanceof MessagesMap)) { 145 return (false); 146 } 147 MessagesMap other = (MessagesMap) o; 148 if (!messages.equals(other.getMessages())) { 149 return (false); 150 } 151 if (locale == null) { 152 return (other.getLocale() == null); 153 } else { 154 return (locale.equals(other.getLocale())); 155 } 156 157 } 158 159 160 165 public Object get(Object key) { 166 167 if (key == null) { 168 return ("??????"); 169 } else { 170 return (messages.getMessage(locale, key.toString())); 171 } 172 173 } 174 175 176 181 public int hashCode() { 182 183 int value = messages.hashCode(); 184 if (locale != null) { 185 value = value ^ locale.hashCode(); 186 } 187 return (value); 188 189 } 190 191 192 196 public boolean isEmpty() { 197 198 return (false); 199 200 } 201 202 203 206 public Set keySet() { 207 208 throw new UnsupportedOperationException (); 209 210 } 211 212 213 219 public Object put(Object key, Object value) { 220 221 throw new UnsupportedOperationException (); 222 223 } 224 225 226 231 public void putAll(Map map) { 232 233 throw new UnsupportedOperationException (); 234 235 } 236 237 238 243 public Object remove(Object key) { 244 245 throw new UnsupportedOperationException (); 246 247 } 248 249 250 253 public int size() { 254 255 throw new UnsupportedOperationException (); 256 257 } 258 259 260 263 public Collection values() { 264 265 throw new UnsupportedOperationException (); 266 267 } 268 269 270 272 273 276 Locale getLocale() { 277 278 return (this.locale); 279 280 } 281 282 283 286 MessageResources getMessages() { 287 288 return (this.messages); 289 290 } 291 292 293 294 } 295 | Popular Tags |