2 * Copyright (c) 2003-2004 Christopher Lenz and others.
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
9 * Christopher Lenz - initial API and implementation
11 * $Id: WebUIMessages.java,v 1.2 2006-10-21 23:13:54 pombredanne Exp $
14 package net.sourceforge.phpeclipse.ui.internal;
16 import java.text.MessageFormat;
17 import java.util.MissingResourceException;
18 import java.util.ResourceBundle;
21 * Utility class that provides easy access to externalized strings.
23 public final class WebUIMessages {
25 // Constants ---------------------------------------------------------------
28 * Qualified name of the resource bundle containing the localized messages.
30 private static final String RESOURCE_BUNDLE = "net.sourceforge.phpeclipse.ui.internal.WebUIMessages"; //$NON-NLS-1$
32 // Class Variables ---------------------------------------------------------
35 * The resource bundle.
37 private static ResourceBundle resourceBundle = ResourceBundle
38 .getBundle(RESOURCE_BUNDLE);
40 // Constructors ------------------------------------------------------------
45 private WebUIMessages() {
49 // Public Methods ----------------------------------------------------------
52 * Returns the resource bundle.
54 * @return the resource bundle
56 public static ResourceBundle getResourceBundle() {
57 return resourceBundle;
61 * Returns the message identified by the specified key.
65 * @return the localized message, or the key enclosed by exclamation marks
66 * if no message was found for the key
68 public static String getString(String key) {
70 return resourceBundle.getString(key);
71 } catch (MissingResourceException e) {
72 return "!" + key + "!"; //$NON-NLS-2$ //$NON-NLS-1$
77 * Returns the message identified by the specified key, replacing a single
78 * parameter with the provided value.
84 * @return the formatted string, or the key enclosed by exclamation marks if
85 * no message was found for the key
87 public static String getString(String key, String arg) {
88 return getString(key, new String[] { arg });
92 * Returns the message identified by the specified key, replacing all
93 * parameters with the provided values.
98 * the parameter values
99 * @return the formatted string, or the key enclosed by exclamation marks if
100 * no message was found for the key
102 public static String getString(String key, String[] args) {
103 return MessageFormat.format(getString(key), args);