KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > celtix > common > i18n > BundleUtils


1 package org.objectweb.celtix.common.i18n;
2
3 import java.util.ResourceBundle JavaDoc;
4
5
6 /**
7  * A container for static utility methods related to resource bundle
8  * naming conventons.
9  */

10 public final class BundleUtils {
11     /**
12      * The resource bundle naming convention for class is a.b.c is a.b.Messages
13      */

14     private static final String JavaDoc MESSAGE_BUNDLE = ".Messages";
15
16     /**
17      * Prevents instantiation.
18      */

19     private BundleUtils() {
20     }
21
22     /**
23      * Encapsulates the logic related to naming a resource bundle.
24      *
25      * @param cls the Class requiring the bundle
26      * @return an appropriate ResourceBundle name
27      */

28     public static String JavaDoc getBundleName(Class JavaDoc cls) {
29         return cls.getPackage().getName() + MESSAGE_BUNDLE;
30     }
31
32     /**
33      * Encapsulates the logic related to locating a resource bundle.
34      *
35      * @param cls the Class requiring the bundle
36      * @return an appropriate ResourceBundle
37      */

38     public static ResourceBundle JavaDoc getBundle(Class JavaDoc cls) {
39         return ResourceBundle.getBundle(getBundleName(cls));
40     }
41 }
42
Popular Tags