3 // Copyright (C) 2015 Christian Jaekl
5 import java.util.Locale;
6 import java.util.MissingResourceException;
7 import java.util.ResourceBundle;
8 import java.util.concurrent.ConcurrentHashMap;
10 import net.jaekl.qd.QDBundleFactory;
12 public class CfbBundle {
13 public static final String CANNOT_CONNECT = "cannot.connect.to.db";
14 public static final String CANNOT_EXEC = "cannot.exec";
15 public static final String STDERR_WAS = "stderr.was";
16 public static final String STDOUT_WAS = "stdout.was";
18 final static String BUNDLE_NAME = "cfb";
20 static ConcurrentHashMap<Locale, CfbBundle> m_bundleMap = new ConcurrentHashMap<Locale, CfbBundle>();
22 ResourceBundle m_bundle;
24 public static CfbBundle getInst(Locale locale) {
25 CfbBundle result = m_bundleMap.get(locale);
27 synchronized(CfbBundle.class) {
28 result = m_bundleMap.get(locale);
30 result = new CfbBundle(locale);
32 m_bundleMap.put(locale, result);
38 private CfbBundle(Locale locale) {
39 m_bundle = QDBundleFactory.getInst().getBundle(BUNDLE_NAME, locale);
42 public String get(String key) {
44 if (null != m_bundle) {
45 return m_bundle.getString(key);
48 catch (MissingResourceException exc) {
49 // Make it clear that something has gone wrong.
50 exc.printStackTrace();
51 // Fall through to the fallback behaviour below
53 return "[" + key + "]";