A mostly working command line (headless) build using PDE build. Still needs some...
[phpeclipse.git] / net.sourceforge.phpeclipse.wizards / src / net / sourceforge / phpeclipse / wizards / actions / metadata / Messages.java
1 package net.sourceforge.phpeclipse.wizards.actions.metadata;
2
3 import java.text.MessageFormat;
4 import java.util.MissingResourceException;
5 import java.util.ResourceBundle;
6
7 public class Messages {
8
9         private static final String BUNDLE_NAME = "net.sourceforge.phpeclipse.wizards.actions.metadata.Messages"; //$NON-NLS-1$
10
11         private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
12
13         private Messages() {
14         }
15
16     public static String getString(Class resourceClass, String key) {
17         return getString(
18             createKey(resourceClass, key));
19     }
20
21     private static String createKey(Class resourceClass, String key) {
22         return resourceClass.getName() + (key.startsWith(".") ? key : "." + key);
23     }
24
25         public static String getString(String key) {
26                 try {
27                         return RESOURCE_BUNDLE.getString(key);
28                 } catch (MissingResourceException e) {
29                         return '!' + key + '!';
30                 }
31         }
32
33     public static String getString(Class resourceClass, String key, Object[] arguments) {
34         return getString(createKey(resourceClass, key), arguments);
35     }
36     
37     public static String getString(String key, Object[] arguments) {
38         String string = getString(key);
39         return MessageFormat.format(string, arguments);
40     }
41 }