1 /*******************************************************************************
2 * Copyright (c) 2003 Berthold Daum.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
10 *******************************************************************************/
12 package net.sourceforge.phpeclipse.wiki.preferences;
14 import java.text.MessageFormat;
15 import java.util.MissingResourceException;
16 import java.util.ResourceBundle;
19 public class Messages {
21 private final static String RESOURCE_BUNDLE= "net.sourceforge.phpeclipse.wiki.preferences.Messages";//$NON-NLS-1$
23 private static ResourceBundle fgResourceBundle = null;
25 private static boolean notRead = true;
29 public static ResourceBundle getResourceBundle() {
33 fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
39 return fgResourceBundle;
41 public static String getString(String key) {
43 return getResourceBundle().getString(key);
44 } catch (Exception e) {
45 return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
50 * Lookup the message with the given ID in this catalog and bind its
51 * substitution locations with the given string.
53 public static String bind(String id, String binding) {
54 return bind(id, new String[] { binding });
58 * Lookup the message with the given ID in this catalog and bind its
59 * substitution locations with the given strings.
61 public static String bind(String id, String binding1, String binding2) {
62 return bind(id, new String[] { binding1, binding2 });
66 * Gets a string from the resource bundle. We don't want to crash because of a missing String.
67 * Returns the key if not found.
69 public static String bind(String key) {
71 return getString(key);
72 } catch (MissingResourceException e) {
74 } catch (NullPointerException e) {
75 return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
80 * Gets a string from the resource bundle and binds it with the given arguments. If the key is
81 * not found, return the key.
83 public static String bind(String key, Object[] args) {
85 return MessageFormat.format(bind(key), args);
86 } catch (MissingResourceException e) {
88 } catch (NullPointerException e) {
89 return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$