286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * Copyright 1999-2004 The Apache Software Foundation.
286N/A *
286N/A * Licensed under the Apache License, Version 2.0 (the "License");
286N/A * you may not use this file except in compliance with the License.
286N/A * You may obtain a copy of the License at
286N/A *
286N/A * http://www.apache.org/licenses/LICENSE-2.0
286N/A *
286N/A * Unless required by applicable law or agreed to in writing, software
286N/A * distributed under the License is distributed on an "AS IS" BASIS,
286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
286N/A * See the License for the specific language governing permissions and
286N/A * limitations under the License.
286N/A */
286N/A
286N/Apackage com.sun.org.apache.xerces.internal.impl.msg;
286N/A
286N/Aimport java.util.Locale;
286N/Aimport java.util.MissingResourceException;
286N/Aimport java.util.ResourceBundle;
286N/Aimport java.util.PropertyResourceBundle;
286N/A
286N/Aimport com.sun.org.apache.xerces.internal.util.MessageFormatter;
524N/Aimport com.sun.org.apache.xerces.internal.utils.SecuritySupport;
286N/A
286N/A/**
286N/A * XMLMessageFormatter provides error messages for the XML 1.0 Recommendation and for
286N/A * the Namespaces Recommendation
286N/A *
286N/A * @xerces.internal
286N/A *
286N/A * @author Eric Ye, IBM
524N/A * @version $Id: XMLMessageFormatter_zh_TW.java 3094 2012-03-21 05:50:01Z joehw $
286N/A *
286N/A */
286N/Apublic class XMLMessageFormatter_zh_TW implements MessageFormatter {
286N/A /**
286N/A * The domain of messages concerning the XML 1.0 specification.
286N/A */
286N/A public static final String XML_DOMAIN = "http://www.w3.org/TR/1998/REC-xml-19980210";
286N/A public static final String XMLNS_DOMAIN = "http://www.w3.org/TR/1999/REC-xml-names-19990114";
286N/A
286N/A // private objects to cache the locale and resource bundle
286N/A private Locale fLocale = null;
286N/A private ResourceBundle fResourceBundle = null;
286N/A
286N/A //
286N/A // MessageFormatter methods
286N/A //
286N/A
286N/A /**
286N/A * Formats a message with the specified arguments using the given
286N/A * locale information.
286N/A *
286N/A * @param locale The locale of the message.
286N/A * @param key The message key.
286N/A * @param arguments The message replacement text arguments. The order
286N/A * of the arguments must match that of the placeholders
286N/A * in the actual message.
286N/A *
286N/A * @return Returns the formatted message.
286N/A *
286N/A * @throws MissingResourceException Thrown if the message with the
286N/A * specified key cannot be found.
286N/A */
286N/A public String formatMessage(Locale locale, String key, Object[] arguments)
286N/A throws MissingResourceException {
286N/A
286N/A if (fResourceBundle == null || locale != fLocale) {
286N/A if (locale != null) {
524N/A fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
286N/A // memorize the most-recent locale
286N/A fLocale = locale;
286N/A }
286N/A if (fResourceBundle == null)
524N/A fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
286N/A }
286N/A
286N/A // format message
286N/A String msg;
286N/A try {
286N/A msg = fResourceBundle.getString(key);
286N/A if (arguments != null) {
286N/A try {
286N/A msg = java.text.MessageFormat.format(msg, arguments);
286N/A }
286N/A catch (Exception e) {
286N/A msg = fResourceBundle.getString("FormatFailed");
286N/A msg += " " + fResourceBundle.getString(key);
286N/A }
286N/A }
286N/A }
286N/A
286N/A // error
286N/A catch (MissingResourceException e) {
286N/A msg = fResourceBundle.getString("BadMessageKey");
286N/A throw new MissingResourceException(key, msg, key);
286N/A }
286N/A
286N/A // no message
286N/A if (msg == null) {
286N/A msg = key;
286N/A if (arguments.length > 0) {
286N/A StringBuffer str = new StringBuffer(msg);
286N/A str.append('?');
286N/A for (int i = 0; i < arguments.length; i++) {
286N/A if (i > 0) {
286N/A str.append('&');
286N/A }
286N/A str.append(String.valueOf(arguments[i]));
286N/A }
286N/A }
286N/A }
286N/A
286N/A return msg;
286N/A }
286N/A
286N/A}