1 57 58 package com.sun.org.apache.xerces.internal.xinclude; 59 60 import java.util.Locale ; 61 import java.util.MissingResourceException ; 62 import java.util.ResourceBundle ; 63 import java.util.PropertyResourceBundle ; 64 import com.sun.org.apache.xerces.internal.util.MessageFormatter; 65 66 74 public class XIncludeMessageFormatter implements MessageFormatter { 75 76 public static final String XINCLUDE_DOMAIN = "http://www.w3.org/TR/xinclude"; 77 78 private Locale fLocale = null; 80 private ResourceBundle fResourceBundle = null; 81 82 97 public String formatMessage(Locale locale, String key, Object [] arguments) 98 throws MissingResourceException { 99 100 if (fResourceBundle == null || locale != fLocale) { 101 if (locale != null) { 102 fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages", locale); 103 fLocale = locale; 105 } 106 if (fResourceBundle == null) 107 fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages"); 108 } 109 110 String msg = fResourceBundle.getString(key); 111 if (arguments != null) { 112 try { 113 msg = java.text.MessageFormat.format(msg, arguments); 114 } catch (Exception e) { 115 msg = fResourceBundle.getString("FormatFailed"); 116 msg += " " + fResourceBundle.getString(key); 117 } 118 } 119 120 if (msg == null) { 121 msg = fResourceBundle.getString("BadMessageKey"); 122 throw new MissingResourceException (msg, "com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages", key); 123 } 124 125 return msg; 126 } 127 } 128 129 | Popular Tags |