KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > views > properties > PropertiesMessages


1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.views.properties;
13
14 import java.text.MessageFormat JavaDoc;
15 import java.util.MissingResourceException JavaDoc;
16 import java.util.ResourceBundle JavaDoc;
17
18 /**
19  * Utility class which helps manage messages.
20  */

21 class PropertiesMessages {
22     private static final String JavaDoc RESOURCE_BUNDLE= "org.eclipse.ui.views.properties.messages";//$NON-NLS-1$
23
private static ResourceBundle JavaDoc bundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
24     
25 private PropertiesMessages(){
26     // prevent instantiation of class
27
}
28 /**
29  * Returns the formatted message for the given key in
30  * the resource bundle.
31  *
32  * @param key the resource name
33  * @param args the message arguments
34  * @return the string
35  */

36 public static String JavaDoc format(String JavaDoc key, Object JavaDoc[] args) {
37     return MessageFormat.format(getString(key),args);
38 }
39 /**
40  * Returns the resource object with the given key in
41  * the resource bundle. If there isn't any value under
42  * the given key, the key is returned.
43  *
44  * @param key the resource name
45  * @return the string
46  */

47 public static String JavaDoc getString(String JavaDoc key) {
48     try {
49         return bundle.getString(key);
50     } catch (MissingResourceException JavaDoc e) {
51         return key;
52     }
53 }
54 }
55
Popular Tags