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

Last change on this file since 858 was 858, checked in by tobias, on Apr 9, 2010 at 10:56:07 AM

visual design slightly modified. tree functions extended

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 key = key.toLowerCase();
28 return properties.getString(key);
29 } catch (Exception e) {
30 System.err.println(key+" / "+e.toString());
31 }
32 return null;
33 }
34 public static String[] getTypeProperties(String partialKey){
35 Enumeration<String> keySet = properties.getKeys();
36 String key;
37 int i = 0;
38 ArrayList<String> result = new ArrayList<String>();
39
40 while(keySet.hasMoreElements()){
41 key = keySet.nextElement();
42 if (key.startsWith(partialKey)){
43 result.add(getProperty(key));
44 }
45 }
46 result.trimToSize();
47 return result.toArray(new String[0]);
48 }
49}
50
Note: See TracBrowser for help on using the repository browser.