1 4 package org.roller.business.hibernate; 5 6 import java.text.MessageFormat ; 7 import java.util.MissingResourceException ; 8 import java.util.ResourceBundle ; 9 10 13 public class Messages 14 { 15 16 private static final String BUNDLE_NAME = 17 "org.roller.business.hibernate.messages"; 19 private static final ResourceBundle RESOURCE_BUNDLE = 20 ResourceBundle.getBundle(BUNDLE_NAME); 21 22 private Messages() 23 { 24 } 25 26 public static String formatString(String key, String [] args) { 27 return MessageFormat.format(getString(key), (Object [])args); 28 } 29 30 public static String formatString(String key, String arg0, String arg1) { 31 return MessageFormat.format(getString(key), (Object [])new String []{arg0,arg1}); 32 } 33 34 public static String formatString(String key, String arg) { 35 return MessageFormat.format(getString(key), (Object [])new String []{arg}); 36 } 37 38 public static String getString(String key) 39 { 40 try 41 { 42 return RESOURCE_BUNDLE.getString(key); 43 } 44 catch (MissingResourceException e) 45 { 46 return '!' + key + '!'; 47 } 48 } 49 } 50 | Popular Tags |