source: vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/PropertyBundle.java@ 857

Last change on this file since 857 was 857, checked in by tobias, on Apr 1, 2010 at 7:02:55 PM

type dependent rendering added

File size: 1.2 KB
Line 
1package de.dass_it.vanhelsing.gui;
2
3import java.util.ArrayList;
4import java.util.Enumeration;
5import java.util.Locale;
6import java.util.ResourceBundle;
7import javax.faces.context.FacesContext;
8
9public class PropertyBundle{
10
11 private static ResourceBundle properties;
12 private static final String path = "de.dass_it.vanhelsing.gui.messages";
13
14 private static void initialize(){
15 Locale l = FacesContext.getCurrentInstance().getViewRoot().getLocale();
16
17 if (l == null){
18 l = Locale.ENGLISH;
19 }
20 properties = ResourceBundle.getBundle(path, l);
21 }
22 public static String getProperty(String key){
23 try{
24 if (properties == null){
25 initialize();
26 }
27 return properties.getString(key);
28 } catch (Exception e) {
29 System.err.println(key+" / "+e.toString());
30 }
31 return null;
32 }
33 public static String[] getTypeProperties(String partialKey){
34 Enumeration<String> keySet = properties.getKeys();
35 String key;
36 int i = 0;
37 ArrayList<String> result = new ArrayList<String>();
38
39 while(keySet.hasMoreElements()){
40 key = keySet.nextElement();
41 if (key.startsWith(partialKey)){
42 result.add(getProperty(key));
43 }
44 }
45 result.trimToSize();
46 return result.toArray(new String[0]);
47 }
48}
49
Note: See TracBrowser for help on using the repository browser.