1 17 18 22 package com.whirlycott.cache; 23 24 import java.text.MessageFormat ; 25 import java.util.Locale ; 26 import java.util.MissingResourceException ; 27 import java.util.ResourceBundle ; 28 29 35 public class Messages { 36 37 private static final String BUNDLE_NAME = "com.whirlycott.cache.MessagesBundle"; 39 private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, Locale.getDefault()); 40 41 private Messages() { 42 } 43 44 public static String getString(final String _key) { 45 try { 46 return RESOURCE_BUNDLE.getString(_key); 47 } catch (final MissingResourceException e) { 48 return '!' + _key + '!'; 49 } 50 } 51 52 53 public static String getCompoundString(final String key, final Object [] args) { 54 final MessageFormat formatter = new MessageFormat (Messages.getString(key)); 55 return formatter.format(args); 56 } 57 } 58 59 | Popular Tags |