1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package net.sf.statcvs;
24
25 import java.util.MissingResourceException;
26 import java.util.ResourceBundle;
27
28 import net.sf.statcvs.output.ConfigurationOptions;
29
30
31
32
33
34
35
36 public class Messages {
37
38
39
40 public static final String WS = " ";
41
42
43
44 public static final String NL = "\n";
45
46 private static final String BUNDLE_NAME = "net.sf.statcvs.statcvs";
47 private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
48
49 private static ResourceBundle primaryResourceBundle = null;
50
51
52
53
54
55
56
57
58 public static String getString(final String key) {
59 final boolean xml = "xml".equalsIgnoreCase(ConfigurationOptions.getOutputFormat());
60 String val = null;
61 try {
62 if (primaryResourceBundle != null) {
63 try {
64 val = primaryResourceBundle.getString(key + (xml ? ".xml" : ""));
65 if (val != null) {
66 return val;
67 }
68 } catch (final MissingResourceException e) {
69 if (xml) {
70 try {
71 val = primaryResourceBundle.getString(key);
72 if (val != null) {
73 return val;
74 }
75 } catch (final MissingResourceException e2) {
76
77 }
78 }
79 }
80 }
81 val = RESOURCE_BUNDLE.getString(key + (xml ? ".xml" : ""));
82 return val;
83 } catch (final MissingResourceException e) {
84 try {
85 if (xml) {
86 val = RESOURCE_BUNDLE.getString(key);
87 if (val != null) {
88 return val;
89 }
90 }
91 return '!' + key + '!';
92 } catch (final MissingResourceException e2) {
93 return '!' + key + '!';
94 }
95 }
96 }
97
98
99
100
101
102
103
104 public static void setPrimaryResource(final String primaryResourceName) {
105 primaryResourceBundle = ResourceBundle.getBundle(primaryResourceName);
106 }
107 }