View Javadoc

1   /* ====================================================================
2    *   Copyright 2003-2005 Fabrizio Giustina.
3    *
4    *   Licensed under the Apache License, Version 2.0 (the "License");
5    *   you may not use this file except in compliance with the License.
6    *   You may obtain a copy of the License at
7    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *   Unless required by applicable law or agreed to in writing, software
11   *   distributed under the License is distributed on an "AS IS" BASIS,
12   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *   See the License for the specific language governing permissions and
14   *   limitations under the License.
15   * ====================================================================
16   */
17  package net.sf.commonclipse;
18  
19  import java.util.MissingResourceException;
20  import java.util.ResourceBundle;
21  
22  
23  /***
24   * @author fgiust
25   * @version $Revision $ ($Author $)
26   */
27  public final class CCMessages
28  {
29  
30      /***
31       * message bundle file name.
32       */
33      private static final String BUNDLE_NAME = "net.sf.commonclipse.messages"; //$NON-NLS-1$
34  
35      /***
36       * resource bundle.
37       */
38      private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
39  
40      /***
41       * don't instantiate.
42       */
43      private CCMessages()
44      {
45      }
46  
47      /***
48       * Returns a String from the resource bundle.
49       * @param key resource key
50       * @return message
51       */
52      public static String getString(String key)
53      {
54          try
55          {
56              return RESOURCE_BUNDLE.getString(key);
57          }
58          catch (MissingResourceException e)
59          {
60              return '!' + key + '!';
61          }
62      }
63  }