--- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/Messages.java Wed Jul 05 18:46:58 2017 +0200
+++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/Messages.java Mon Feb 18 11:33:35 2013 -0800
@@ -22,6 +22,7 @@
*/
package com.sun.org.apache.xml.internal.serializer.utils;
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
import java.util.ListResourceBundle;
import java.util.Locale;
import java.util.MissingResourceException;
@@ -87,9 +88,6 @@
* can have the Message strings translated in an alternate language
* in a errorResourceClass with a language suffix.
*
- * More sophisticated use of this class would be to pass null
- * when contructing it, but then call loadResourceBundle()
- * before creating any messages.
*
* This class is not a public API, it is only public because it is
* used in com.sun.org.apache.xml.internal.serializer.
@@ -126,18 +124,6 @@
m_resourceBundleName = resourceBundle;
}
- /*
- * Set the Locale object to use. If this method is not called the
- * default locale is used. This method needs to be called before
- * loadResourceBundle().
- *
- * @param locale non-null reference to Locale object.
- * @xsl.usage internal
- */
-// public void setLocale(Locale locale)
-// {
-// m_locale = locale;
-// }
/**
* Get the Locale object that is being used.
@@ -151,16 +137,6 @@
}
/**
- * Get the ListResourceBundle being used by this Messages instance which was
- * previously set by a call to loadResourceBundle(className)
- * @xsl.usage internal
- */
- private ListResourceBundle getResourceBundle()
- {
- return m_resourceBundle;
- }
-
- /**
* Creates a message from the specified key and replacement
* arguments, localized to the given locale.
*
@@ -174,7 +150,7 @@
public final String createMessage(String msgKey, Object args[])
{
if (m_resourceBundle == null)
- m_resourceBundle = loadResourceBundle(m_resourceBundleName);
+ m_resourceBundle = SecuritySupport.getResourceBundle(m_resourceBundleName);
if (m_resourceBundle != null)
{
@@ -293,76 +269,4 @@
return fmsg;
}
- /**
- * Return a named ResourceBundle for a particular locale. This method mimics the behavior
- * of ResourceBundle.getBundle().
- *
- * @param className the name of the class that implements ListResourceBundle,
- * without language suffix.
- * @return the ResourceBundle
- * @throws MissingResourceException
- * @xsl.usage internal
- */
- private ListResourceBundle loadResourceBundle(String resourceBundle)
- throws MissingResourceException
- {
- m_resourceBundleName = resourceBundle;
- Locale locale = getLocale();
-
- ListResourceBundle lrb;
-
- try
- {
-
- ResourceBundle rb =
- ResourceBundle.getBundle(m_resourceBundleName, locale);
- lrb = (ListResourceBundle) rb;
- }
- catch (MissingResourceException e)
- {
- try // try to fall back to en_US if we can't load
- {
-
- // Since we can't find the localized property file,
- // fall back to en_US.
- lrb =
- (ListResourceBundle) ResourceBundle.getBundle(
- m_resourceBundleName,
- new Locale("en", "US"));
- }
- catch (MissingResourceException e2)
- {
-
- // Now we are really in trouble.
- // very bad, definitely very bad...not going to get very far
- throw new MissingResourceException(
- "Could not load any resource bundles." + m_resourceBundleName,
- m_resourceBundleName,
- "");
- }
- }
- m_resourceBundle = lrb;
- return lrb;
- }
-
- /**
- * Return the resource file suffic for the indicated locale
- * For most locales, this will be based the language code. However
- * for Chinese, we do distinguish between Taiwan and PRC
- *
- * @param locale the locale
- * @return an String suffix which can be appended to a resource name
- * @xsl.usage internal
- */
- private static String getResourceSuffix(Locale locale)
- {
-
- String suffix = "_" + locale.getLanguage();
- String country = locale.getCountry();
-
- if (country.equals("TW"))
- suffix += "_" + country;
-
- return suffix;
- }
}