1 16 17 package test.utils; 18 19 import org.apache.axis.i18n.MessageBundle; 20 import org.apache.axis.i18n.MessagesConstants; 21 22 import java.util.Locale ; 23 import java.util.MissingResourceException ; 24 import java.util.ResourceBundle ; 25 26 27 36 public class Messages { 37 private static final Class thisClass = Messages.class; 38 39 private static final String projectName = "test.utils"; 40 41 private static final String resourceName = MessagesConstants.resourceName; 42 private static final Locale locale = MessagesConstants.locale; 43 44 private static final String packageName = getPackage(thisClass.getName()); 45 private static final ClassLoader classLoader = thisClass.getClassLoader(); 46 47 private static final ResourceBundle parent = 48 (MessagesConstants.rootPackageName == packageName) 49 ? null 50 : MessagesConstants.rootBundle; 51 52 53 54 55 private static final MessageBundle messageBundle = 56 new MessageBundle(projectName, packageName, resourceName, 57 locale, classLoader, parent); 58 59 66 public static String getMessage(String key) 67 throws MissingResourceException 68 { 69 return messageBundle.getMessage(key); 70 } 71 72 80 public static String getMessage(String key, String arg0) 81 throws MissingResourceException 82 { 83 return messageBundle.getMessage(key, arg0); 84 } 85 86 95 public static String getMessage(String key, String arg0, String arg1) 96 throws MissingResourceException 97 { 98 return messageBundle.getMessage(key, arg0, arg1); 99 } 100 101 111 public static String getMessage(String key, String arg0, String arg1, String arg2) 112 throws MissingResourceException 113 { 114 return messageBundle.getMessage(key, arg0, arg1, arg2); 115 } 116 117 128 public static String getMessage(String key, String arg0, String arg1, String arg2, String arg3) 129 throws MissingResourceException 130 { 131 return messageBundle.getMessage(key, arg0, arg1, arg2, arg3); 132 } 133 134 146 public static String getMessage(String key, String arg0, String arg1, String arg2, String arg3, String arg4) 147 throws MissingResourceException 148 { 149 return messageBundle.getMessage(key, arg0, arg1, arg2, arg3, arg4); 150 } 151 152 160 public static String getMessage(String key, String [] args) 161 throws MissingResourceException 162 { 163 return messageBundle.getMessage(key, args); 164 } 165 166 public static ResourceBundle getResourceBundle() { 167 return messageBundle.getResourceBundle(); 168 } 169 170 public static MessageBundle getMessageBundle() { 171 return messageBundle; 172 } 173 174 private static final String getPackage(String name) { 175 return name.substring(0, name.lastIndexOf('.')).intern(); 176 } 177 } 178 | Popular Tags |