1 7 8 22 23 package java.util; 24 25 92 public abstract class ListResourceBundle extends ResourceBundle { 93 97 public ListResourceBundle() { 98 } 99 100 public final Object handleGetObject(String key) { 102 if (lookup == null) { 104 loadLookup(); 105 } 106 if (key == null) { 107 throw new NullPointerException (); 108 } 109 return lookup.get(key); } 111 112 115 public Enumeration <String > getKeys() { 116 if (lookup == null) { 118 loadLookup(); 119 } 120 121 ResourceBundle parent = this.parent; 122 return new ResourceBundleEnumeration (lookup.keySet(), 123 (parent != null) ? parent.getKeys() : null); 124 } 125 126 129 abstract protected Object [][] getContents(); 130 131 133 137 private synchronized void loadLookup() { 138 if (lookup != null) 139 return; 140 141 Object [][] contents = getContents(); 142 HashMap temp = new HashMap (contents.length); 143 for (int i = 0; i < contents.length; ++i) { 144 String key = (String ) contents[i][0]; 146 Object value = contents[i][1]; 147 if (key == null || value == null) { 148 throw new NullPointerException (); 149 } 150 temp.put(key, value); 151 } 152 lookup = temp; 153 } 154 155 private Map lookup = null; 156 } 157 | Popular Tags |