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