129
|
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 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13
|
|
14 module dwtx.jface.text.source.JFaceTextMessages;
|
|
15
|
|
16 import dwt.dwthelper.utils;
|
|
17
|
|
18 import java.util.MissingResourceException;
|
|
19 import java.util.ResourceBundle;
|
|
20
|
|
21 import com.ibm.icu.text.MessageFormat;
|
|
22
|
|
23 /**
|
|
24 * Accessor for the <code>JFaceTextMessages.properties</code> file in
|
|
25 * package <code>dwtx.jface.text</code>.
|
|
26 * @since 2.0
|
|
27 */
|
|
28 class JFaceTextMessages {
|
|
29
|
|
30 /** The resource bundle name. */
|
|
31 private static final String RESOURCE_BUNDLE= "dwtx.jface.text.JFaceTextMessages";//$NON-NLS-1$
|
|
32
|
|
33 /** The resource bundle. */
|
|
34 private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
|
|
35
|
|
36 /**
|
|
37 * Prohibits the creation of accessor objects.
|
|
38 */
|
|
39 private JFaceTextMessages() {
|
|
40 }
|
|
41
|
|
42 /**
|
|
43 * Returns the string found in the resource bundle under the given key or a place holder string.
|
|
44 *
|
|
45 * @param key the look up key
|
|
46 * @return the value found under the given key
|
|
47 */
|
|
48 public static String getString(String key) {
|
|
49 try {
|
|
50 return fgResourceBundle.getString(key);
|
|
51 } catch (MissingResourceException e) {
|
|
52 return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
|
53 }
|
|
54 }
|
|
55
|
|
56 /**
|
|
57 * Gets a string from the resource bundle and formats it with the argument
|
|
58 *
|
|
59 * @param key the string used to get the bundle value, must not be null
|
|
60 * @param args arguments used when formatting the string
|
|
61 * @return the formatted string
|
|
62 * @since 3.0
|
|
63 */
|
|
64 public static String getFormattedString(String key, Object[] args) {
|
|
65 String format= null;
|
|
66 try {
|
|
67 format= fgResourceBundle.getString(key);
|
|
68 } catch (MissingResourceException e) {
|
|
69 return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
|
70 }
|
|
71 return MessageFormat.format(format, args);
|
|
72 }
|
|
73 }
|