1 23 24 package com.sun.enterprise.config.backup; 25 26 import java.util.ResourceBundle ; 27 import java.text.MessageFormat ; 28 29 33 class StringHelper 34 { 35 private StringHelper() 36 { 37 } 38 39 42 43 static String get(String s) 44 { 45 try 46 { 47 return bundle.getString(s); 48 } 49 catch (Exception e) 50 { 51 return s; 53 } 54 } 55 56 62 static String get(String s, Object o) 63 { 64 return get(s, new Object [] { o }); 65 } 66 67 73 static String get(String s, Object o1, Object o2) 74 { 75 return get(s, new Object [] { o1, o2 }); 76 } 77 78 84 static String get(String s, Object o1, Object o2, Object o3) 85 { 86 return get(s, new Object [] { o1, o2, o3 }); 87 } 88 89 94 static String get(String s, Object [] objects) 95 { 96 s = get(s); 97 98 try 99 { 100 MessageFormat mf = new MessageFormat (s); 101 return mf.format(objects); 102 } 103 catch(Exception e) 104 { 105 return s; 106 } 107 } 108 109 111 private static ResourceBundle bundle; 112 113 static 114 { 115 try 116 { 117 String props = StringHelper.class.getPackage().getName() + ".LocalStrings"; 118 bundle = ResourceBundle.getBundle(props); 119 } 120 catch (Exception e) 121 { 122 LoggerHelper.warning("No resource bundle found: " + Constants.exceptionResourceBundle, e); 123 bundle = null; 124 } 125 } 126 127 static void main(String [] notUsed) 128 { 129 System.out.println("key=backup-res.BadProjectBackupDir, value =" + get("backup-res.BadProjectBackupDir")); 130 } 131 } 132 133 134 | Popular Tags |