Add unit tests. Make DbStore handle cases where the bug type or category
[cfb.git] / prod / net / jaekl / cfb / CfbBundle.java
index 335a68dfbbb761c914b5523fee10115bba5e75e9..5f5aa9ee8b52ce303cf45c623a8853800c32b1e4 100644 (file)
@@ -2,6 +2,7 @@ package net.jaekl.cfb;
 
 // Copyright (C) 2015 Christian Jaekl
 
+import java.text.MessageFormat;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
@@ -11,10 +12,27 @@ import net.jaekl.qd.QDBundleFactory;
 
 public class CfbBundle {
        public static final String ANALYSIS_FAILED = "analysis.failed";
+       public static final String ANALYZED_AT = "analyzed.at";
+       public static final String BUG_CATEGORY_UNKNOWN = "bug.category.unknown";
+       public static final String BUG_TYPE_UNKNOWN = "bug.type.unknown";
        public static final String CANNOT_CONNECT = "cannot.connect.to.db";
        public static final String CANNOT_EXEC = "cannot.exec";
+       public static final String CANNOT_SEND_MAIL = "cannot.send.mail";
+       public static final String CFB = "cfb";
+       public static final String CFB_MAIL_SUBJECT = "cfb.mail.subject";
+       public static final String CFB_REPORT = "cfb.report";
+       public static final String COMPARING_RUNS = "comparing.runs";
+       public static final String COMPARING_VERSIONS = "comparing.versions";
+       public static final String FIXED_BUGS = "fixed.bugs";
+       public static final String NEW_BUGS = "new.bugs";
+       public static final String NEW_VERSION = "new.version";
+       public static final String NUM_BUGS = "num.bugs";
+       public static final String NUM_BUGS_OLD = "num.bugs.old";
+       public static final String OLD_BUGS = "old.bugs";
+       public static final String OLD_VERSION = "old.version";
        public static final String STDERR_WAS = "stderr.was";
        public static final String STDOUT_WAS = "stdout.was";
+       public static final String VERSION_NUM = "version.num";
        
        final static String BUNDLE_NAME = "cfb";
        
@@ -40,10 +58,11 @@ public class CfbBundle {
                m_bundle = QDBundleFactory.getInst().getBundle(BUNDLE_NAME, locale); 
        }
        
-       public String get(String key) {
+       public String get(String key, Object... arguments) {
                try {
                        if (null != m_bundle) {
-                               return m_bundle.getString(key);
+                               String pattern = m_bundle.getString(key);
+                               return MessageFormat.format(pattern, arguments);
                        }
                }
                catch (MissingResourceException exc) {
@@ -51,6 +70,11 @@ public class CfbBundle {
                        exc.printStackTrace();  
                        // Fall through to the fallback behaviour below
                }
-               return "[" + key + "]";
+               
+               StringBuilder sb = new StringBuilder("[" + key + "]");
+               for (Object obj : arguments) {
+                       sb.append("[" + obj + "]");
+               }
+               return sb.toString();
        }
 }