1 4 package com.tc.util; 5 6 import java.text.MessageFormat ; 7 import java.util.ResourceBundle ; 8 9 public class ResourceBundleHelper { 10 private ResourceBundle bundle; 11 12 public ResourceBundleHelper(Class clas) { 13 bundle = AbstractResourceBundleFactory.getBundle(clas); 14 } 15 16 public Object getObject(final String key) { 17 Assert.assertNotNull(key); 18 return bundle.getObject(key); 19 } 20 21 public String getString(final String key) { 22 Assert.assertNotNull(key); 23 return bundle.getString(key); 24 } 25 26 public String format(final String key, Object [] args) { 27 Assert.assertNotNull(key); 28 String fmt = getString(key); 29 Assert.assertNotNull(fmt); 30 return MessageFormat.format(fmt, args); 31 } 32 } 33 | Popular Tags |