1 16 17 package org.apache.xerces.xinclude; 18 19 import java.util.Locale ; 20 import java.util.MissingResourceException ; 21 import java.util.ResourceBundle ; 22 import java.util.PropertyResourceBundle ; 23 import org.apache.xerces.util.MessageFormatter; 24 25 33 public class XIncludeMessageFormatter implements MessageFormatter { 34 35 public static final String XINCLUDE_DOMAIN = "http://www.w3.org/TR/xinclude"; 36 37 private Locale fLocale = null; 39 private ResourceBundle fResourceBundle = null; 40 41 56 public String formatMessage(Locale locale, String key, Object [] arguments) 57 throws MissingResourceException { 58 59 if (fResourceBundle == null || locale != fLocale) { 60 if (locale != null) { 61 fResourceBundle = PropertyResourceBundle.getBundle("org.apache.xerces.impl.msg.XIncludeMessages", locale); 62 fLocale = locale; 64 } 65 if (fResourceBundle == null) 66 fResourceBundle = PropertyResourceBundle.getBundle("org.apache.xerces.impl.msg.XIncludeMessages"); 67 } 68 69 String msg = fResourceBundle.getString(key); 70 if (arguments != null) { 71 try { 72 msg = java.text.MessageFormat.format(msg, arguments); 73 } catch (Exception e) { 74 msg = fResourceBundle.getString("FormatFailed"); 75 msg += " " + fResourceBundle.getString(key); 76 } 77 } 78 79 if (msg == null) { 80 msg = fResourceBundle.getString("BadMessageKey"); 81 throw new MissingResourceException (msg, "org.apache.xerces.impl.msg.XIncludeMessages", key); 82 } 83 84 return msg; 85 } 86 } | Popular Tags |