misc changes
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpeclipse / ui / preferences / PHPPreferencesMessages.java
1 package net.sourceforge.phpeclipse.ui.preferences;
2
3 import java.text.MessageFormat;
4 import java.util.MissingResourceException;
5 import java.util.ResourceBundle;
6
7 public class PHPPreferencesMessages {
8
9         private static final String RESOURCE_BUNDLE= PHPPreferencesMessages.class.getName();
10         private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
11
12         private PHPPreferencesMessages() {
13         }
14
15         public static String getString(String key) {
16                 try {
17                         return fgResourceBundle.getString(key);
18                 } catch (MissingResourceException e) {
19                         return '!' + key + '!';
20                 }
21         }
22         
23         /**
24          * Gets a string from the resource bundle and formats it with the argument
25          * 
26          * @param key   the string used to get the bundle value, must not be null
27          */
28         public static String getFormattedString(String key, Object arg) {
29                 return MessageFormat.format(getString(key), new Object[] { arg });
30         }
31
32
33         /**
34          * Gets a string from the resource bundle and formats it with arguments
35          */     
36         public static String getFormattedString(String key, Object[] args) {
37                 return MessageFormat.format(getString(key), args);
38         }
39 }