1 21 package com.presumo.jms.resources; 22 23 import java.text.MessageFormat ; 24 import java.util.Locale ; 25 import java.util.MissingResourceException ; 26 import java.util.ResourceBundle ; 27 28 31 public final class Resources 32 { 33 public static final String RESOURCE_BUNDLE_LOC = 34 "com.presumo.jms.resources.jms"; 35 36 private static ResourceBundle resources; 37 static { 38 try { 39 resources = ResourceBundle.getBundle(RESOURCE_BUNDLE_LOC, 40 Locale.getDefault()); 41 } catch (MissingResourceException mre) { 42 System.err.println(RESOURCE_BUNDLE_LOC + " not found."); 43 System.exit(1); 44 } 45 } 46 47 public static ResourceBundle getBundle() 48 { 49 return resources; 50 } 51 52 public static String getResourceString(String key) 53 { 54 String str; 55 try { 56 str = resources.getString(key); 57 } catch (MissingResourceException mre) { 58 str = null; 59 } 60 return str; 61 } 62 63 public static String getResourceString(String key, Object param) 64 { 65 return getResourceString(key, new Object [] { param }); 66 } 67 68 public static String getResourceString(String key, Object [] params) 69 { 70 String str = getResourceString(key); 71 if (str != null) 72 str = MessageFormat.format(str, params); 73 74 return str; 75 } 76 } | Popular Tags |