1 18 19 package org.apache.roller.util; 20 21 import java.text.MessageFormat ; 22 import java.util.List ; 23 import java.util.ResourceBundle ; 24 import org.apache.commons.logging.Log; 25 import org.apache.commons.logging.LogFactory; 26 27 28 31 public class MessageUtilities { 32 33 private static Log log = LogFactory.getLog(MessageUtilities.class); 34 35 private static final ResourceBundle bundle = 36 ResourceBundle.getBundle("ApplicationResources"); 37 38 39 private MessageUtilities() { 41 } 42 43 44 47 public static final String getString(String key) { 48 49 try { 50 return bundle.getString(key); 51 } catch (Exception e) { 52 log.warn("Error getting key "+key, e); 54 return key; 55 } 56 } 57 58 59 63 public static final String getString(String key, List args) { 64 65 try { 66 String msg = bundle.getString(key); 67 return MessageFormat.format(msg, args.toArray()); 68 } catch (Exception e) { 69 log.warn("Error getting key "+key, e); 71 return key; 72 } 73 } 74 75 76 80 public static final String getString(String key, Object [] args) { 81 82 try { 83 String msg = bundle.getString(key); 84 return MessageFormat.format(msg, args); 85 } catch (Exception e) { 86 log.warn("Error getting key "+key, e); 88 return key; 89 } 90 } 91 92 } 93 | Popular Tags |