1 9 package org.jboss.portal.common.util; 10 11 import java.util.Enumeration ; 12 import java.util.HashMap ; 13 import java.util.Locale ; 14 import java.util.Map ; 15 import java.util.ResourceBundle ; 16 17 29 public class ParentChildResourceBundle extends ResourceBundle 30 { 31 32 private Locale locale; 33 private Map values; 34 35 43 public ParentChildResourceBundle(ResourceBundle parent, ResourceBundle child) throws IllegalArgumentException 44 { 45 if (child == null) 47 { 48 throw new IllegalArgumentException ("Child cannot be null"); 49 } 50 this.locale = child.getLocale(); 51 this.values = new HashMap (); 52 53 if (parent != null) 55 { 56 for (Enumeration e = parent.getKeys();e.hasMoreElements();) 57 { 58 String key = (String )e.nextElement(); 59 Object value = parent.getObject(key); 60 values.put(key, value); 61 } 62 } 63 64 for (Enumeration e = child.getKeys();e.hasMoreElements();) 66 { 67 String key = (String )e.nextElement(); 68 Object value = child.getObject(key); 69 values.put(key, value); 70 } 71 } 72 73 public Locale getLocale() 74 { 75 return locale; 76 } 77 78 protected Object handleGetObject(String key) 79 { 80 return values.get(key); 81 } 82 83 public Enumeration getKeys() 84 { 85 return Tools.toEnumeration(values.keySet().iterator()); 86 } 87 } 88 | Popular Tags |