added class fields to outline
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / text / java / hover / JavaHoverMessages.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.phpdt.internal.ui.text.java.hover;
12
13 import java.text.MessageFormat;
14 import java.util.MissingResourceException;
15 import java.util.ResourceBundle;
16
17 class JavaHoverMessages {
18
19         private static final String RESOURCE_BUNDLE= "net.sourceforge.phpdt.internal.ui.text.java.hover.JavaHoverMessages";//$NON-NLS-1$
20
21         private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
22
23         private JavaHoverMessages() {
24         }
25
26         public static String getString(String key) {
27                 try {
28                         return fgResourceBundle.getString(key);
29                 } catch (MissingResourceException e) {
30                         return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
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          * @since 3.0
38          */
39         public static String getFormattedString(String key, Object arg) {
40                 String format= null;
41                 try {
42                         format= fgResourceBundle.getString(key);
43                 } catch (MissingResourceException e) {
44                         return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
45                 }
46                 if (arg == null)
47                         arg= ""; //$NON-NLS-1$
48                 return MessageFormat.format(format, new Object[] { arg });
49         }
50         /**
51          * Gets a string from the resource bundle and formats it with the arguments
52          * 
53          * @param key   the string used to get the bundle value, must not be null
54          * @since 3.0
55          */
56         public static String getFormattedString(String key, Object arg1, Object arg2) {
57                 String format= null;
58                 try {
59                         format= fgResourceBundle.getString(key);
60                 } catch (MissingResourceException e) {
61                         return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
62                 }
63                 if (arg1 == null)
64                         arg1= ""; //$NON-NLS-1$
65                 if (arg2 == null)
66                         arg2= ""; //$NON-NLS-1$
67                 return MessageFormat.format(format, new Object[] { arg1, arg2 });
68         }
69         
70         /**
71          * Gets a string from the resource bundle and formats it with the argument
72          * 
73          * @param key   the string used to get the bundle value, must not be null
74          * @since 3.0
75          */
76         public static String getFormattedString(String key, boolean arg) {
77                 String format= null;
78                 try {
79                         format= fgResourceBundle.getString(key);
80                 } catch (MissingResourceException e) {
81                         return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
82                 }
83                 return MessageFormat.format(format, new Object[] { new Boolean(arg) });
84         }
85 }