Changes:
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / obfuscator / export / ObfuscatorExportMessages.java
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 package net.sourceforge.phpeclipse.obfuscator.export;
12  
13 import java.text.MessageFormat;
14 import java.util.MissingResourceException;
15 import java.util.ResourceBundle;
16
17 /**
18  * Utility class which helps managing messages
19  */
20 class ObfuscatorExportMessages {
21         private static final String RESOURCE_BUNDLE= "net.sourceforge.phpeclipse.obfuscator.export.messages";//$NON-NLS-1$
22         private static ResourceBundle bundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
23 private ObfuscatorExportMessages(){
24         // prevent instantiation of class
25 }
26 /**
27  * Returns the formatted message for the given key in
28  * the resource bundle. 
29  *
30  * @param key the resource name
31  * @param args the message arguments
32  * @return the string
33  */     
34 public static String format(String key, Object[] args) {
35         return MessageFormat.format(getString(key),args);
36 }
37 /**
38  * Returns the resource object with the given key in
39  * the resource bundle. If there isn't any value under
40  * the given key, the key is returned.
41  *
42  * @param key the resource name
43  * @return the string
44  */     
45 public static String getString(String key) {
46         try {
47                 return bundle.getString(key);
48         } catch (MissingResourceException e) {
49                 return key;
50         }
51 }
52 }