summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.java')
-rw-r--r--plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.java
new file mode 100644
index 0000000..8fe40d3
--- /dev/null
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.java
@@ -0,0 +1,56 @@
1/*******************************************************************************
2 * Copyright (c) 2010 Intel Corporation.
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 * Intel - initial API and implementation
10 *******************************************************************************/
11package org.yocto.sdk.ide;
12
13import java.text.MessageFormat;
14import java.util.MissingResourceException;
15import java.util.ResourceBundle;
16
17public class YoctoSDKMessages {
18 private static final String RESOURCE_BUNDLE= YoctoSDKMessages.class.getName();
19 private static ResourceBundle fgResourceBundle;
20 static {
21 try {
22 fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
23 } catch (MissingResourceException x) {
24 fgResourceBundle = null;
25 }
26 }
27
28 private YoctoSDKMessages() {
29 }
30
31 public static String getString(String key) {
32 try {
33 return fgResourceBundle.getString(key);
34 } catch (MissingResourceException e) {
35 return '!' + key + '!';
36 } catch (NullPointerException e) {
37 return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$
38 }
39 }
40
41 /**
42 * Gets a string from the resource bundle and formats it with the argument
43 *
44 * @param key the string used to get the bundle value, must not be null
45 */
46 public static String getFormattedString(String key, Object arg) {
47 return MessageFormat.format(getString(key), new Object[] { arg });
48 }
49
50 /**
51 * Gets a string from the resource bundle and formats it with arguments
52 */
53 public static String getFormattedString(String key, Object[] args) {
54 return MessageFormat.format(getString(key), args);
55 }
56}