1 22 23 package org.continuent.sequoia.common.i18n; 24 25 import java.text.MessageFormat ; 26 import java.util.MissingResourceException ; 27 import java.util.ResourceBundle ; 28 29 36 37 public final class JmxTranslate 38 { 39 42 private static final String BUNDLE_NAME = "org.continuent.sequoia.common.i18n.mbean-messages"; 44 47 private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle 48 .getBundle(BUNDLE_NAME); 49 50 53 private JmxTranslate() 54 { 55 } 56 57 64 public static String get(String key) 65 { 66 try 67 { 68 return RESOURCE_BUNDLE.getString(key); 69 } 70 catch (MissingResourceException e) 71 { 72 return '!' + key + '!'; 73 } 74 } 75 76 85 public static String get(String key, Object [] args) 86 { 87 try 88 { 89 return MessageFormat.format(RESOURCE_BUNDLE.getString(key), args); 90 } 91 catch (MissingResourceException e) 92 { 93 return '!' + key + '!'; 94 } 95 } 96 97 100 103 public static String get(String key, boolean parameter) 104 { 105 return get(key, new Object []{Boolean.valueOf(parameter)}); 106 } 107 108 111 public static String get(String key, int parameter) 112 { 113 return get(key, new Object []{Integer.toString(parameter)}); 114 } 115 116 119 public static String get(String key, long parameter) 120 { 121 return get(key, new Object []{Long.toString(parameter)}); 122 } 123 124 127 public static String get(String key, Object parameter) 128 { 129 return get(key, new Object []{parameter}); 130 } 131 } | Popular Tags |