View Javadoc
1   /*
2    * Copyright 2004 Diogo Quintela (dquintela@users.sourceforge.net)
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  package net.sf.whatsnew.lang;
17  
18  import java.util.MissingResourceException;
19  import java.util.ResourceBundle;
20  
21  
22  /***
23   * <p>
24   * Utility class for Application messages grab
25   * </p>
26   *
27   * @author <a href="mailto:dquintela@users.sourceforge.net">Diogo Quintela</a>
28   * @version $Id: Messages.java,v 1.1 2004/05/13 01:22:33 dquintela Exp $
29   */
30  public class Messages {
31      /*** Bundle name/location */
32      private static final String MESSAGES_NAME = "net.sf.whatsnew.lang.messages";  //$NON-NLS-1$
33  
34      /*** Resource bundle for messages */
35      private static final ResourceBundle MESSAGES_BUNDLE = ResourceBundle
36              .getBundle(MESSAGES_NAME);
37  
38      /***
39       * Creates a new Messages object.<br>
40       * Disable instantiation
41       */
42      private Messages() {
43      	// Disable instantiation
44      }
45  
46      /***
47       * Obtain message based on key value
48       *
49       * @param key The key to lookup for
50       *
51       * @return The message
52       */
53      public static String getString(String key) {
54          try {
55              return MESSAGES_BUNDLE.getString(key);
56          } catch (MissingResourceException e) {
57              return '!' + key + '!';
58          }
59      }
60  }
61  // EOF