1 57 58 package com.sun.org.apache.xerces.internal.impl.xs; 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 67 74 public class XSMessageFormatter implements MessageFormatter { 75 78 public static final String SCHEMA_DOMAIN = "http://www.w3.org/TR/xml-schema-1"; 79 80 81 private Locale fLocale = null; 83 private ResourceBundle fResourceBundle = null; 84 85 100 public String formatMessage(Locale locale, String key, Object [] arguments) 101 throws MissingResourceException { 102 103 if (fResourceBundle == null || locale != fLocale) { 104 if (locale != null) { 105 fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", locale); 106 fLocale = locale; 108 } 109 if (fResourceBundle == null) 110 fResourceBundle = PropertyResourceBundle.getBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages"); 111 } 112 113 String msg = fResourceBundle.getString(key); 114 if (arguments != null) { 115 try { 116 msg = java.text.MessageFormat.format(msg, arguments); 117 } catch (Exception e) { 118 msg = fResourceBundle.getString("FormatFailed"); 119 msg += " " + fResourceBundle.getString(key); 120 } 121 } 122 123 if (msg == null) { 124 msg = fResourceBundle.getString("BadMessageKey"); 125 throw new MissingResourceException (msg, "com.sun.org.apache.xerces.internal.impl.msg.SchemaMessages", key); 126 } 127 128 return msg; 129 } 130 } 131 | Popular Tags |