KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > business > hibernate > Messages


1 /*
2  * Created on Sep 14, 2003
3  */

4 package org.roller.business.hibernate;
5
6 import java.text.MessageFormat JavaDoc;
7 import java.util.MissingResourceException JavaDoc;
8 import java.util.ResourceBundle JavaDoc;
9
10 /**
11  * @author dmj
12  */

13 public class Messages
14 {
15
16     private static final String JavaDoc BUNDLE_NAME =
17         "org.roller.business.hibernate.messages"; //$NON-NLS-1$
18

19     private static final ResourceBundle JavaDoc RESOURCE_BUNDLE =
20         ResourceBundle.getBundle(BUNDLE_NAME);
21
22     private Messages()
23     {
24     }
25     
26     public static String JavaDoc formatString(String JavaDoc key, String JavaDoc[] args) {
27         return MessageFormat.format(getString(key), (Object JavaDoc[])args);
28     }
29     
30     public static String JavaDoc formatString(String JavaDoc key, String JavaDoc arg0, String JavaDoc arg1) {
31         return MessageFormat.format(getString(key), (Object JavaDoc[])new String JavaDoc[]{arg0,arg1});
32     }
33     
34     public static String JavaDoc formatString(String JavaDoc key, String JavaDoc arg) {
35         return MessageFormat.format(getString(key), (Object JavaDoc[])new String JavaDoc[]{arg});
36     }
37     
38     public static String JavaDoc getString(String JavaDoc key)
39     {
40         try
41         {
42             return RESOURCE_BUNDLE.getString(key);
43         }
44         catch (MissingResourceException JavaDoc e)
45         {
46             return '!' + key + '!';
47         }
48     }
49 }
50
Popular Tags