KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > text > templates > TextTemplateMessages


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.jface.text.templates;
12
13 import com.ibm.icu.text.MessageFormat;
14 import java.util.MissingResourceException JavaDoc;
15 import java.util.ResourceBundle JavaDoc;
16
17 /*
18  * @since 3.0
19  */

20 class TextTemplateMessages {
21
22     private static final String JavaDoc RESOURCE_BUNDLE= TextTemplateMessages.class.getName();
23     private static ResourceBundle JavaDoc fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
24
25     private TextTemplateMessages() {
26     }
27
28     public static String JavaDoc getString(String JavaDoc key) {
29         try {
30             return fgResourceBundle.getString(key);
31         } catch (MissingResourceException JavaDoc e) {
32             return '!' + key + '!';
33         }
34     }
35
36     public static String JavaDoc getFormattedString(String JavaDoc key, Object JavaDoc arg) {
37         return MessageFormat.format(getString(key), new Object JavaDoc[] { arg });
38     }
39
40
41     public static String JavaDoc getFormattedString(String JavaDoc key, Object JavaDoc[] args) {
42         return MessageFormat.format(getString(key), args);
43     }
44 }
45
Popular Tags