KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > util > ResourceBundleHelper


1 /**
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

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