View Javadoc

1   /*
2    * To change this template, choose Tools | Templates
3    * and open the template in the editor.
4    */
5   
6   package com.rc.celeritas.i18n;
7   
8   import com.rc.celeritas.exception.CeleritasException;
9   import java.util.ResourceBundle;
10  import org.apache.log4j.Logger;
11  
12  /**
13   *
14   * @author rchoudhary
15   */
16  public class ResourceHelper {
17      private static ResourceBundle rb;
18  
19      private static boolean _initialized = false;
20  
21      private static Logger log = Logger.getLogger(ResourceHelper.class);
22  
23      /**
24       * 
25       * @return
26       * @throws com.rc.celeritas.exception.CeleritasException
27       */
28      public static boolean init() throws CeleritasException{
29          if(_initialized){
30              return _initialized;
31          }
32          try{
33              rb = ResourceBundle.getBundle("messages");
34          }catch(Exception e){
35              log.error("Error in Initializing RB " + e.toString());
36              throw new CeleritasException(e);
37          }
38          return _initialized = true;
39      }
40  
41      /**
42       *
43       * @param key
44       * @return
45       */
46      public String getValue(String key){
47          return rb.getString(key);
48      }
49  }