KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > actions > FoldingMessages


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

11 package org.eclipse.jdt.internal.ui.actions;
12
13 import com.ibm.icu.text.MessageFormat;
14 import java.util.MissingResourceException JavaDoc;
15 import java.util.ResourceBundle JavaDoc;
16
17 /**
18  * Class that gives access to the folding messages resource bundle.
19  */

20 public class FoldingMessages {
21
22     private static final String JavaDoc BUNDLE_NAME= "org.eclipse.jdt.internal.ui.actions.FoldingMessages"; //$NON-NLS-1$
23

24     private static final ResourceBundle JavaDoc RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME);
25
26     private FoldingMessages() {
27         // no instance
28
}
29
30     /**
31      * Returns the resource string associated with the given key in the resource bundle. If there isn't
32      * any value under the given key, the key is returned.
33      *
34      * @param key the resource key
35      * @return the string
36      */

37     public static String JavaDoc getString(String JavaDoc key) {
38         try {
39             return RESOURCE_BUNDLE.getString(key);
40         } catch (MissingResourceException JavaDoc e) {
41             return '!' + key + '!';
42         }
43     }
44     
45     /**
46      * Returns the resource bundle managed by the receiver.
47      *
48      * @return the resource bundle
49      * @since 3.0
50      */

51     public static ResourceBundle JavaDoc getResourceBundle() {
52         return RESOURCE_BUNDLE;
53     }
54     
55     /**
56      * Returns the formatted resource string associated with the given key in the resource bundle.
57      * <code>MessageFormat</code> is used to format the message. If there isn't any value
58      * under the given key, the key is returned.
59      *
60      * @param key the resource key
61      * @param arg the message argument
62      * @return the string
63      */

64     public static String JavaDoc getFormattedString(String JavaDoc key, Object JavaDoc arg) {
65         return getFormattedString(key, new Object JavaDoc[] { arg });
66     }
67     
68     /**
69      * Returns the formatted resource string associated with the given key in the resource bundle.
70      * <code>MessageFormat</code> is used to format the message. If there isn't any value
71      * under the given key, the key is returned.
72      *
73      * @param key the resource key
74      * @param args the message arguments
75      * @return the string
76      */

77     public static String JavaDoc getFormattedString(String JavaDoc key, Object JavaDoc[] args) {
78         return MessageFormat.format(getString(key), args);
79     }
80 }
81
Popular Tags