KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > examples > jet > article2 > ui > WizardMessages


1 package org.eclipse.emf.examples.jet.article2.ui;
2
3
4 import java.text.MessageFormat JavaDoc;
5 import java.util.MissingResourceException JavaDoc;
6 import java.util.ResourceBundle JavaDoc;
7
8 import org.eclipse.core.runtime.Platform;
9
10 import org.eclipse.emf.examples.jet.article2.TypesafeEnumPlugin;
11
12
13 /**
14  * Convenience class for getting strings from a resource bundle.
15  *
16  * @author Remko Popma
17  * @version $Revision: 1.2 $ ($Date: 2004/06/01 16:17:41 $)
18  */

19 public class WizardMessages
20 {
21   private static final ResourceBundle JavaDoc RESOURCE_BUNDLE = Platform.getResourceBundle(TypesafeEnumPlugin.getDefault().getBundle());
22
23   private WizardMessages()
24   {
25   }
26
27   public static String JavaDoc getString(String JavaDoc key)
28   {
29     try
30     {
31       return RESOURCE_BUNDLE.getString(key);
32     }
33     catch (MissingResourceException JavaDoc e)
34     {
35       return '!' + key + '!';
36     }
37   }
38
39   /**
40    * Gets a string from the resource bundle and formats it with the argument
41    *
42    * @param key
43    * the string used to get the bundle value, must not be null
44    */

45   public static String JavaDoc getFormattedString(String JavaDoc key, Object JavaDoc arg)
46   {
47     return MessageFormat.format(getString(key), new Object JavaDoc []{ arg });
48   }
49
50   /**
51    * Gets a string from the resource bundle and formats it with arguments
52    */

53   public static String JavaDoc getFormattedString(String JavaDoc key, Object JavaDoc[] args)
54   {
55     return MessageFormat.format(getString(key), args);
56   }
57
58 }
Popular Tags