KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > views > tasklist > TaskListMessages


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

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

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