1 23 package com.sun.enterprise.admin.util; 24 25 import java.util.ResourceBundle ; 26 import java.util.Locale ; 27 import java.util.Hashtable ; 28 import java.text.MessageFormat ; 29 30 31 41 42 public class SOMLocalStringsManager extends LocalStringsManager 43 { 44 private static final String DEFAULT_PROPERTY_FILE_NAME = "bundle"; 45 private static final String DEFAULT_PACKAGE_NAME = "com.sun.enterprise.admin"; 46 48 49 private static Hashtable managers = new Hashtable (); 50 51 public SOMLocalStringsManager(String packageName) 52 { 53 super(packageName, DEFAULT_PROPERTY_FILE_NAME); 54 setFixedResourceBundle(packageName); 55 } 56 57 64 public synchronized static SOMLocalStringsManager getManager(String packageName) { 65 66 SOMLocalStringsManager mgr = (SOMLocalStringsManager) managers.get(packageName); 67 68 if (mgr == null) { 69 mgr = new SOMLocalStringsManager(packageName); 70 try { 71 managers.put(packageName, mgr); 72 } catch (Exception e) { 73 } 75 } 76 return mgr; 77 } 78 79 87 public synchronized static SOMLocalStringsManager getManager(Class callerClass) { 88 89 try { 90 int dotIdx = callerClass.getName().lastIndexOf("."); 91 if (dotIdx != -1) { 92 String pkgName = callerClass.getName().substring(0, dotIdx); 93 return getManager(pkgName); 94 } else { 95 String pkgName = callerClass.getName(); 97 return getManager(pkgName); 98 } 99 } catch (Exception e) { 100 return getManager(DEFAULT_PACKAGE_NAME); 103 } 104 } 105 106 111 public String getString( String key) 112 { 113 return super.getString(key, key); } 116 117 123 public String getString( String key, String defaultValue) 124 { 125 return super.getString(key, defaultValue); 126 } 127 128 134 public String getString( String key, Object [] args) 135 { 136 return super.getString(key, key, args); 137 } 138 139 146 public String getString( String key, String defaultFormat, Object [] args) 147 { 148 return super.getString(key, defaultFormat, args); 149 } 150 151 158 public String getString( String key, String defaultFormat, Object arg1) 159 { 160 return getString(key, defaultFormat, (new Object []{arg1})); 161 } 162 163 171 public String getString( String key, String defaultFormat, Object arg1, Object arg2) 172 { 173 return getString(key, defaultFormat, (new Object []{arg1, arg2})); 174 } 175 176 185 public String getString( String key, String defaultFormat, Object arg1, Object arg2, Object arg3) 186 { 187 return getString(key, defaultFormat, (new Object []{arg1, arg2, arg3})); 188 } 189 } | Popular Tags |