+package net.jaekl.cfb;
+
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.concurrent.ConcurrentHashMap;
+
+import net.jaekl.qd.QDBundleFactory;
+
+public class CfbBundle {
+ public static final String CANNOT_CONNECT = "cannot.connect.to.db";
+
+ final static String BUNDLE_NAME = "cfb";
+
+ static ConcurrentHashMap<Locale, CfbBundle> m_bundleMap = new ConcurrentHashMap<Locale, CfbBundle>();
+
+ ResourceBundle m_bundle;
+
+ public static CfbBundle getInst(Locale locale) {
+ CfbBundle result = m_bundleMap.get(locale);
+ if (null == result) {
+ synchronized(CfbBundle.class) {
+ result = m_bundleMap.get(locale);
+ if (null == result) {
+ result = new CfbBundle(locale);
+ }
+ m_bundleMap.put(locale, result);
+ }
+ }
+ return result;
+ }
+
+ private CfbBundle(Locale locale) {
+ m_bundle = QDBundleFactory.getInst().getBundle(BUNDLE_NAME, locale);
+ }
+
+ public String get(String key) {
+ try {
+ if (null != m_bundle) {
+ return m_bundle.getString(key);
+ }
+ }
+ catch (MissingResourceException exc) {
+ // Make it clear that something has gone wrong.
+ exc.printStackTrace();
+ // Fall through to the fallback behaviour below
+ }
+ return "[" + key + "]";
+ }
+}