diff options
author | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 13:36:50 +0100 |
---|---|---|
committer | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 15:25:03 +0100 |
commit | 41ac47d732eed8392d60d0f6773e5a279d49b999 (patch) | |
tree | cf19d099db9cfdb8d73aa21c31e7aa1cc86ff860 /plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.java | |
download | eclipse-poky-juno-master.tar.gz |
Migrated from the internal git server on the dora-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
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.java | 56 |
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 | *******************************************************************************/ | ||
11 | package org.yocto.sdk.ide; | ||
12 | |||
13 | import java.text.MessageFormat; | ||
14 | import java.util.MissingResourceException; | ||
15 | import java.util.ResourceBundle; | ||
16 | |||
17 | public 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 | } | ||