1 package cintoo.messages.bundle; 2 3 import api.cintoo.messages.bundle.BaseBundle; 4 5 import java.io.IOException ; 6 import java.io.InputStream ; 7 import java.util.*; 8 9 public class BaseResourceBundle extends BaseBundle { 10 private Map<String , String > messages; 11 private Locale currentLocale; 12 13 public Locale getLocale() { 14 return currentLocale; 15 } 16 17 public BaseResourceBundle(Locale locale) { 18 this.currentLocale = locale; 19 } 20 21 public BaseResourceBundle(InputStream stream, Locale locale) throws IOException { 22 Properties properties = new Properties(); 23 properties.load(stream); 24 messages = new HashMap(properties); 25 this.currentLocale = locale; 26 } 27 28 protected Object handleGetObject(String key) { 29 if (null == key) { 30 throw new NullPointerException (); 31 } 32 return messages.get(key); 33 } 34 35 public Enumeration<String > getKeys() { 36 ResourceBundle parent = this.parent; 37 return Collections.enumeration(messages.keySet()); 39 } 40 } 41 | Popular Tags |