01: package org.objectweb.celtix.common.i18n;
02:
03: import java.util.ResourceBundle;
04:
05: /**
06: * A container for static utility methods related to resource bundle
07: * naming conventons.
08: */
09: public final class BundleUtils {
10: /**
11: * The resource bundle naming convention for class is a.b.c is a.b.Messages
12: */
13: private static final String MESSAGE_BUNDLE = ".Messages";
14:
15: /**
16: * Prevents instantiation.
17: */
18: private BundleUtils() {
19: }
20:
21: /**
22: * Encapsulates the logic related to naming a resource bundle.
23: *
24: * @param cls the Class requiring the bundle
25: * @return an appropriate ResourceBundle name
26: */
27: public static String getBundleName(Class cls) {
28: return cls.getPackage().getName() + MESSAGE_BUNDLE;
29: }
30:
31: /**
32: * Encapsulates the logic related to locating a resource bundle.
33: *
34: * @param cls the Class requiring the bundle
35: * @return an appropriate ResourceBundle
36: */
37: public static ResourceBundle getBundle(Class cls) {
38: return ResourceBundle.getBundle(getBundleName(cls));
39: }
40: }
|