KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cintoo > messages > bundle > BaseResourceBundle


1 package cintoo.messages.bundle;
2
3 import api.cintoo.messages.bundle.BaseBundle;
4
5 import java.io.IOException JavaDoc;
6 import java.io.InputStream JavaDoc;
7 import java.util.*;
8
9 public class BaseResourceBundle extends BaseBundle {
10   private Map<String JavaDoc, String JavaDoc> 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 JavaDoc stream, Locale locale) throws IOException JavaDoc {
22     Properties properties = new Properties();
23     properties.load(stream);
24     messages = new HashMap(properties);
25     this.currentLocale = locale;
26   }
27
28   protected Object JavaDoc handleGetObject(String JavaDoc key) {
29     if (null == key) {
30       throw new NullPointerException JavaDoc();
31     }
32     return messages.get(key);
33   }
34
35   public Enumeration<String JavaDoc> getKeys() {
36     ResourceBundle parent = this.parent;
37     // need to add parent keys
38
return Collections.enumeration(messages.keySet());
39   }
40 }
41
Popular Tags