KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > junit > runner > JUnitMessages


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  * David Saff (saff@mit.edu) - bug 102632: [JUnit] Support for JUnit 4.
11  *******************************************************************************/

12 package org.eclipse.jdt.internal.junit.runner;
13
14 import java.text.MessageFormat JavaDoc;
15 import java.util.MissingResourceException JavaDoc;
16 import java.util.ResourceBundle JavaDoc;
17
18 public class JUnitMessages {
19
20     private static final String JavaDoc BUNDLE_NAME= "org.eclipse.jdt.internal.junit.runner.JUnitMessages"; //$NON-NLS-1$
21

22     private static final ResourceBundle JavaDoc RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME);
23
24     private JUnitMessages() {
25     }
26
27     /**
28      * Gets a string from the resource bundle and formats it with the argument
29      *
30      * @param key the string used to get the bundle value, must not be null
31      */

32     public static String JavaDoc getFormattedString(String JavaDoc key, Object JavaDoc arg) {
33         return MessageFormat.format(getString(key), new Object JavaDoc[] { arg });
34     }
35
36     /**
37      * Gets a string from the resource bundle and formats it with arguments
38      */

39     public static String JavaDoc getFormattedString(String JavaDoc key, Object JavaDoc[] args) {
40         return MessageFormat.format(getString(key), args);
41     }
42
43     public static String JavaDoc getString(String JavaDoc key) {
44         try {
45             return RESOURCE_BUNDLE.getString(key);
46         } catch (MissingResourceException JavaDoc e) {
47             return '!' + key + '!';
48         }
49     }
50 }
51
Popular Tags