aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/messages
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-05-14 11:35:43 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-05-14 11:35:43 +0200
commit87cd5e8be869b19e6b37dbb13056882efff976a0 (patch)
tree4941cc941b9a791037869967b47df6fa56effe30 /pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/messages
parent1d5e1f5f429d225e14f4ce9e6e82a403eac10b6b (diff)
downloadpdf-as-4-87cd5e8be869b19e6b37dbb13056882efff976a0.tar.gz
pdf-as-4-87cd5e8be869b19e6b37dbb13056882efff976a0.tar.bz2
pdf-as-4-87cd5e8be869b19e6b37dbb13056882efff976a0.zip
Added Verification Messages
Diffstat (limited to 'pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/messages')
-rw-r--r--pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/messages/CodesResolver.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/messages/CodesResolver.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/messages/CodesResolver.java
new file mode 100644
index 00000000..f98e8d07
--- /dev/null
+++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/messages/CodesResolver.java
@@ -0,0 +1,44 @@
+package at.gv.egiz.pdfas.common.messages;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CodesResolver {
+ private static final String messageResource = "resources.messages.verify";
+ private static final String missingMsg = "Unknown ";
+
+ private static final Logger logger = LoggerFactory.getLogger(MessageResolver.class);
+
+ private static ResourceBundle bundle;
+
+ static {
+ bundle = ResourceBundle.getBundle(messageResource);
+ if(bundle == null) {
+ logger.error("Failed to load resource bundle!!");
+ System.err.println("Failed to load resource bundle!!");
+ //Runtime.getRuntime().exit(-1);
+ }
+ }
+
+ public static void forceLocale(Locale locale) {
+ bundle = ResourceBundle.getBundle(messageResource, locale);
+ }
+
+ public static String resolveMessage(String msgId) {
+ if(bundle == null) {
+ return missingMsg + msgId;
+ }
+ if(bundle.containsKey(msgId)) {
+ String value = bundle.getString(msgId);
+ if(value == null) {
+ return missingMsg + msgId;
+ }
+ return value;
+ }
+ return missingMsg + msgId;
+ }
+
+}