View Javadoc

1   /*
2    * Created on Jul 21, 2005. Copyright 1999-2006 Faculty of Mathematics, Physics
3    * and Informatics, Comenius University, Bratislava. This file is protected by
4    * the Mozilla Public License version 1.1 (the "License"); you may not use this
5    * file except in compliance with the License. You may obtain a copy of the
6    * License at http://euromath2.sourceforge.net/license.html Unless required by
7    * applicable law or agreed to in writing, software distributed under the
8    * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9    * OF ANY KIND, either express or implied. See the License for the specific
10   * language governing permissions and limitations under the License.
11   */
12  package sk.uniba.euromath.gene.lang;
13  import java.util.MissingResourceException;
14  import java.util.ResourceBundle;
15  import sk.uniba.euromath.tools.LangTools;
16  import sk.uniba.euromath.tools.StringTools;
17  /***
18   * Language files for the GENE package.
19   * @author Martin Vysny
20   */
21  public class Messages {
22  	private static final String BUNDLE_NAME = "sk.uniba.euromath.gene.lang.messages"; //$NON-NLS-1$
23  	private static final ResourceBundle RESOURCE_BUNDLE = LangTools.newBundle(BUNDLE_NAME, Messages.class);
24  	private Messages() {
25  		// disallow instantiation
26  	}
27  	/***
28  	 * Gets message for given key.
29  	 * @param key key in the properties file.
30  	 * @return message associated with the key.
31  	 */
32  	public static String getString(String key) {
33  		// TODO Auto-generated method stub
34  		try {
35  			return RESOURCE_BUNDLE.getString(key);
36  		} catch (MissingResourceException e) {
37  			return '!' + key + '!';
38  		}
39  	}
40  	/***
41  	 * Gets message for given key.
42  	 * @param key key in the properties file.
43  	 * @param params message variable part replacements
44  	 * @return message associated with the key.
45  	 */
46  	public static String getString(String key, Object... params) {
47  		try {
48  			String msg = RESOURCE_BUNDLE.getString(key);
49  			return StringTools.format(msg, params);
50  		} catch (MissingResourceException e) {
51  			return '!' + key + '!';
52  		}
53  	}
54  }