*/
public static String formatMessage(Locale locale,
String key, Object[] arguments)
throws MissingResourceException {
ResourceBundle resourceBundle = null;
if (locale != null) {
resourceBundle =
PropertyResourceBundle.getBundle(BASE_NAME, locale);
}
else {
resourceBundle =
PropertyResourceBundle.getBundle(BASE_NAME);
}
// format message
String msg;
try {
msg = resourceBundle.getString(key);
if (arguments != null) {
try {
msg = java.text.MessageFormat.format(msg, arguments);
}
catch (Exception e) {
msg = resourceBundle.getString("FormatFailed");
msg += " " + resourceBundle.getString(key);
}
}
}
// error
catch (MissingResourceException e) {
msg = resourceBundle.getString("BadMessageKey");
throw new MissingResourceException(key, msg, key);
}
// no message
if (msg == null) {