--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2003 Berthold Daum.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Berthold Daum
+ *******************************************************************************/
+
+package net.sourceforge.phpeclipse.wiki.actions.category;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+
+public class Messages {
+
+ private final static String RESOURCE_BUNDLE= "net.sourceforge.phpeclipse.wiki.actions.category.Messages";//$NON-NLS-1$
+
+ private static ResourceBundle fgResourceBundle = null;
+
+ private static boolean notRead = true;
+
+ public Messages() {
+ }
+ public static ResourceBundle getResourceBundle() {
+ if (notRead) {
+ notRead = false;
+ try {
+ fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
+ }
+ catch (Exception e) {
+ }
+ }
+
+ return fgResourceBundle;
+ }
+ public static String getString(String key) {
+ try {
+ return getResourceBundle().getString(key);
+ } catch (Exception e) {
+ return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Lookup the message with the given ID in this catalog and bind its
+ * substitution locations with the given string.
+ */
+ public static String bind(String id, String binding) {
+ return bind(id, new String[] { binding });
+ }
+
+ /**
+ * Lookup the message with the given ID in this catalog and bind its
+ * substitution locations with the given strings.
+ */
+ public static String bind(String id, String binding1, String binding2) {
+ return bind(id, new String[] { binding1, binding2 });
+ }
+
+ /**
+ * Gets a string from the resource bundle. We don't want to crash because of a missing String.
+ * Returns the key if not found.
+ */
+ public static String bind(String key) {
+ try {
+ return getString(key);
+ } catch (MissingResourceException e) {
+ return key;
+ } catch (NullPointerException e) {
+ return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * Gets a string from the resource bundle and binds it with the given arguments. If the key is
+ * not found, return the key.
+ */
+ public static String bind(String key, Object[] args) {
+ try {
+ return MessageFormat.format(bind(key), args);
+ } catch (MissingResourceException e) {
+ return key;
+ } catch (NullPointerException e) {
+ return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+}
+