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 ANALYSIS_FAILED = "analysis.failed";
14 public static final String CANNOT_CONNECT = "cannot.connect.to.db";
15 public static final String CANNOT_EXEC = "cannot.exec";
16 public static final String STDERR_WAS = "stderr.was";
17 public static final String STDOUT_WAS = "stdout.was";
19 final static String BUNDLE_NAME = "cfb";
21 static ConcurrentHashMap<Locale, CfbBundle> m_bundleMap = new ConcurrentHashMap<Locale, CfbBundle>();
23 ResourceBundle m_bundle;
25 public static CfbBundle getInst(Locale locale) {
26 CfbBundle result = m_bundleMap.get(locale);
28 synchronized(CfbBundle.class) {
29 result = m_bundleMap.get(locale);
31 result = new CfbBundle(locale);
33 m_bundleMap.put(locale, result);
39 private CfbBundle(Locale locale) {
40 m_bundle = QDBundleFactory.getInst().getBundle(BUNDLE_NAME, locale);
43 public String get(String key) {
45 if (null != m_bundle) {
46 return m_bundle.getString(key);
49 catch (MissingResourceException exc) {
50 // Make it clear that something has gone wrong.
51 exc.printStackTrace();
52 // Fall through to the fallback behaviour below
54 return "[" + key + "]";