2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
5 package org.ufcspa.simdecs.diagram.util;
7 import java.text.MessageFormat;
8 import java.util.Locale;
9 import java.util.MissingResourceException;
10 import java.util.ResourceBundle;
16 public class MessageResourceUtils {
18 protected static ClassLoader getCurrentClassLoader(Object defaultObject) {
20 ClassLoader loader = Thread.currentThread().getContextClassLoader();
23 loader = defaultObject.getClass().getClassLoader();
29 public static String getMessageResourceString(
37 ResourceBundle bundle =
38 ResourceBundle.getBundle(bundleName, locale,
39 getCurrentClassLoader(params));
42 text = bundle.getString(key);
43 } catch (MissingResourceException e) {
44 text = "?? key " + key + " not found ??";
48 MessageFormat mf = new MessageFormat(text, locale);
49 text = mf.format(params, new StringBuffer(), null).toString();