1 12 package org.displaytag; 13 14 import java.text.MessageFormat ; 15 import java.util.MissingResourceException ; 16 import java.util.ResourceBundle ; 17 18 19 24 public final class Messages 25 { 26 27 30 private static final String BUNDLE_NAME = "org.displaytag.messages"; 32 35 private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); 36 37 40 private Messages() 41 { 42 } 44 45 50 public static String getString(String key) 51 { 52 try 53 { 54 return RESOURCE_BUNDLE.getString(key); 55 } 56 catch (MissingResourceException e) 57 { 58 return '!' + key + '!'; 59 } 60 } 61 62 68 public static String getString(String key, Object [] parameters) 69 { 70 String baseMsg; 71 try 72 { 73 baseMsg = RESOURCE_BUNDLE.getString(key); 74 } 75 catch (MissingResourceException e) 76 { 77 return '!' + key + '!'; 78 } 79 80 return MessageFormat.format(baseMsg, parameters); 81 } 82 83 89 public static String getString(String key, Object parameter) 90 { 91 return getString(key, new Object []{parameter}); 92 } 93 } | Popular Tags |