1 package org.xnap.commons.i18n; 2 3 import java.util.Enumeration; 4 import java.util.Locale; 5 import java.util.ResourceBundle; 6 7 /** 8 * A <code>ResourceBundle</code> that returns the key as a value. 9 * 10 * FIXME needs to implement proper plural handling 11 * FIXME the bundle needs to have a valid locale for proper sourceCodeLocale handling 12 */ 13 class EmptyResourceBundle extends ResourceBundle 14 { 15 private Locale locale; 16 17 public EmptyResourceBundle(Locale locale) 18 { 19 this.locale = locale; 20 } 21 22 /** 23 * Returns the key as value. 24 */ 25 protected Object handleGetObject(String key) 26 { 27 return key; 28 } 29 30 public Enumeration getKeys() 31 { 32 return new EmptyStringEnumeration(); 33 } 34 35 public Locale getLocale() 36 { 37 return locale; 38 } 39 40 private static class EmptyStringEnumeration implements Enumeration 41 { 42 43 public boolean hasMoreElements() 44 { 45 return false; 46 } 47 48 public Object nextElement() 49 { 50 throw new IllegalStateException("nextElement must not be " + 51 "called on empty enumeration"); 52 } 53 54 } 55 56 }