improved PHP parser
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / corext / codemanipulation / CodeGenerationMessages.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 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.phpdt.internal.corext.codemanipulation;
12
13 import java.text.MessageFormat;
14 import java.util.MissingResourceException;
15 import java.util.ResourceBundle;
16
17 public class CodeGenerationMessages {
18
19         private static final String RESOURCE_BUNDLE= CodeGenerationMessages.class.getName();
20         private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
21
22         private CodeGenerationMessages() {
23         }
24
25         public static String getString(String key) {
26                 try {
27                         return fgResourceBundle.getString(key);
28                 } catch (MissingResourceException e) {
29                         return '!' + key + '!';
30                 }
31         }
32         
33         /**
34          * Gets a string from the resource bundle and formats it with the argument
35          * 
36          * @param key   the string used to get the bundle value, must not be null
37          */
38         public static String getFormattedString(String key, Object arg) {
39                 return MessageFormat.format(getString(key), new Object[] { arg });
40         }
41
42
43         /**
44          * Gets a string from the resource bundle and formats it with arguments
45          */     
46         public static String getFormattedString(String key, Object[] args) {
47                 return MessageFormat.format(getString(key), args);
48         }
49
50
51 }