Java Code Examples for com.sun.org.apache.xerces.internal.utils.SecuritySupport#getResourceBundle()

The following examples show how to use com.sun.org.apache.xerces.internal.utils.SecuritySupport#getResourceBundle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DatatypeException.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Overrides this method to get the formatted&localized error message.
 *
 * REVISIT: the system locale is used to load the property file.
 *          do we want to allow the appilcation to specify a
 *          different locale?
 */
public String getMessage() {
    ResourceBundle resourceBundle = null;
    resourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages");
    if (resourceBundle == null)
        throw new MissingResourceException("Property file not found!", "com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", key);

    String msg = resourceBundle.getString(key);
    if (msg == null) {
        msg = resourceBundle.getString("BadMessageKey");
        throw new MissingResourceException(msg, "com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", key);
    }

    if (args != null) {
        try {
            msg = java.text.MessageFormat.format(msg, args);
        } catch (Exception e) {
            msg = resourceBundle.getString("FormatFailed");
            msg += " " + resourceBundle.getString(key);
        }
    }

    return msg;
}
 
Example 2
Source File: XPointerMessageFormatter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Formats a message with the specified arguments using the given locale
 * information.
 *
 * @param locale
 *            The locale of the message.
 * @param key
 *            The message key.
 * @param arguments
 *            The message replacement text arguments. The order of the
 *            arguments must match that of the placeholders in the actual
 *            message.
 *
 * @return Returns the formatted message.
 *
 * @throws MissingResourceException
 *             Thrown if the message with the specified key cannot be found.
 */
public String formatMessage(Locale locale, String key, Object[] arguments)
        throws MissingResourceException {

    if (fResourceBundle == null || locale != fLocale) {
        if (locale != null) {
            fResourceBundle = SecuritySupport.getResourceBundle(
                    "com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages", locale);
            // memorize the most-recent locale
            fLocale = locale;
        }
        if (fResourceBundle == null)
            fResourceBundle = SecuritySupport.getResourceBundle(
                    "com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages");
    }

    String msg = fResourceBundle.getString(key);
    if (arguments != null) {
        try {
            msg = java.text.MessageFormat.format(msg, arguments);
        } catch (Exception e) {
            msg = fResourceBundle.getString("FormatFailed");
            msg += " " + fResourceBundle.getString(key);
        }
    }

    if (msg == null) {
        msg = fResourceBundle.getString("BadMessageKey");
        throw new MissingResourceException(msg,
                "com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages", key);
    }

    return msg;
}
 
Example 3
Source File: XPointerMessageFormatter.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Formats a message with the specified arguments using the given locale
 * information.
 *
 * @param locale
 *            The locale of the message.
 * @param key
 *            The message key.
 * @param arguments
 *            The message replacement text arguments. The order of the
 *            arguments must match that of the placeholders in the actual
 *            message.
 *
 * @return Returns the formatted message.
 *
 * @throws MissingResourceException
 *             Thrown if the message with the specified key cannot be found.
 */
public String formatMessage(Locale locale, String key, Object[] arguments)
        throws MissingResourceException {

    if (fResourceBundle == null || locale != fLocale) {
        if (locale != null) {
            fResourceBundle = SecuritySupport.getResourceBundle(
                    "com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages", locale);
            // memorize the most-recent locale
            fLocale = locale;
        }
        if (fResourceBundle == null)
            fResourceBundle = SecuritySupport.getResourceBundle(
                    "com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages");
    }

    String msg = fResourceBundle.getString(key);
    if (arguments != null) {
        try {
            msg = java.text.MessageFormat.format(msg, arguments);
        } catch (Exception e) {
            msg = fResourceBundle.getString("FormatFailed");
            msg += " " + fResourceBundle.getString(key);
        }
    }

    if (msg == null) {
        msg = fResourceBundle.getString("BadMessageKey");
        throw new MissingResourceException(msg,
                "com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages", key);
    }

    return msg;
}
 
Example 4
Source File: RegexParser.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public void setLocale(Locale locale) {
    try {
        if (locale != null) {
            this.resources = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message", locale);
        }
        else {
            this.resources = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message");
        }
    }
    catch (MissingResourceException mre) {
        throw new RuntimeException("Installation Problem???  Couldn't load messages: "
                                   + mre.getMessage());
    }
}
 
Example 5
Source File: XIncludeMessageFormatter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Formats a message with the specified arguments using the given
 * locale information.
 *
 * @param locale    The locale of the message.
 * @param key       The message key.
 * @param arguments The message replacement text arguments. The order
 *                  of the arguments must match that of the placeholders
 *                  in the actual message.
 *
 * @return Returns the formatted message.
 *
 * @throws MissingResourceException Thrown if the message with the
 *                                  specified key cannot be found.
 */
 public String formatMessage(Locale locale, String key, Object[] arguments)
    throws MissingResourceException {

    if (fResourceBundle == null || locale != fLocale) {
        if (locale != null) {
            fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages", locale);
            // memorize the most-recent locale
            fLocale = locale;
        }
        if (fResourceBundle == null)
            fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages");
    }

    String msg = fResourceBundle.getString(key);
    if (arguments != null) {
        try {
            msg = java.text.MessageFormat.format(msg, arguments);
        } catch (Exception e) {
            msg = fResourceBundle.getString("FormatFailed");
            msg += " " + fResourceBundle.getString(key);
        }
    }

    if (msg == null) {
        msg = fResourceBundle.getString("BadMessageKey");
        throw new MissingResourceException(msg, "com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages", key);
    }

    return msg;
}
 
Example 6
Source File: XPointerMessageFormatter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Formats a message with the specified arguments using the given locale
 * information.
 *
 * @param locale
 *            The locale of the message.
 * @param key
 *            The message key.
 * @param arguments
 *            The message replacement text arguments. The order of the
 *            arguments must match that of the placeholders in the actual
 *            message.
 *
 * @return Returns the formatted message.
 *
 * @throws MissingResourceException
 *             Thrown if the message with the specified key cannot be found.
 */
public String formatMessage(Locale locale, String key, Object[] arguments)
        throws MissingResourceException {

    if (fResourceBundle == null || locale != fLocale) {
        if (locale != null) {
            fResourceBundle = SecuritySupport.getResourceBundle(
                    "com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages", locale);
            // memorize the most-recent locale
            fLocale = locale;
        }
        if (fResourceBundle == null)
            fResourceBundle = SecuritySupport.getResourceBundle(
                    "com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages");
    }

    String msg = fResourceBundle.getString(key);
    if (arguments != null) {
        try {
            msg = java.text.MessageFormat.format(msg, arguments);
        } catch (Exception e) {
            msg = fResourceBundle.getString("FormatFailed");
            msg += " " + fResourceBundle.getString(key);
        }
    }

    if (msg == null) {
        msg = fResourceBundle.getString("BadMessageKey");
        throw new MissingResourceException(msg,
                "com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages", key);
    }

    return msg;
}
 
Example 7
Source File: XSMessageFormatter.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Formats a message with the specified arguments using the given
 * locale information.
 *
 * @param locale    The locale of the message.
 * @param key       The message key.
 * @param arguments The message replacement text arguments. The order
 *                  of the arguments must match that of the placeholders
 *                  in the actual message.
 *
 * @return Returns the formatted message.
 *
 * @throws MissingResourceException Thrown if the message with the
 *                                  specified key cannot be found.
 */
 public String formatMessage(Locale locale, String key, Object[] arguments)
    throws MissingResourceException {

    if (fResourceBundle == null || locale != fLocale) {
        if (locale != null) {
            fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", locale);
            // memorize the most-recent locale
            fLocale = locale;
        }
        if (fResourceBundle == null)
            fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages");
    }

    String msg = fResourceBundle.getString(key);
    if (arguments != null) {
        try {
            msg = java.text.MessageFormat.format(msg, arguments);
        } catch (Exception e) {
            msg = fResourceBundle.getString("FormatFailed");
            msg += " " + fResourceBundle.getString(key);
        }
    }

    if (msg == null) {
        msg = fResourceBundle.getString("BadMessageKey");
        throw new MissingResourceException(msg, "com.sun.org.apache.xerces.internal.impl.msg.SchemaMessages", key);
    }

    return msg;
}
 
Example 8
Source File: XSMessageFormatter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Formats a message with the specified arguments using the given
 * locale information.
 *
 * @param locale    The locale of the message.
 * @param key       The message key.
 * @param arguments The message replacement text arguments. The order
 *                  of the arguments must match that of the placeholders
 *                  in the actual message.
 *
 * @return Returns the formatted message.
 *
 * @throws MissingResourceException Thrown if the message with the
 *                                  specified key cannot be found.
 */
 public String formatMessage(Locale locale, String key, Object[] arguments)
    throws MissingResourceException {

    if (fResourceBundle == null || locale != fLocale) {
        if (locale != null) {
            fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", locale);
            // memorize the most-recent locale
            fLocale = locale;
        }
        if (fResourceBundle == null)
            fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages");
    }

    String msg = fResourceBundle.getString(key);
    if (arguments != null) {
        try {
            msg = java.text.MessageFormat.format(msg, arguments);
        } catch (Exception e) {
            msg = fResourceBundle.getString("FormatFailed");
            msg += " " + fResourceBundle.getString(key);
        }
    }

    if (msg == null) {
        msg = fResourceBundle.getString("BadMessageKey");
        throw new MissingResourceException(msg, "com.sun.org.apache.xerces.internal.impl.msg.SchemaMessages", key);
    }

    return msg;
}
 
Example 9
Source File: XPointerMessageFormatter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Formats a message with the specified arguments using the given locale
 * information.
 *
 * @param locale
 *            The locale of the message.
 * @param key
 *            The message key.
 * @param arguments
 *            The message replacement text arguments. The order of the
 *            arguments must match that of the placeholders in the actual
 *            message.
 *
 * @return Returns the formatted message.
 *
 * @throws MissingResourceException
 *             Thrown if the message with the specified key cannot be found.
 */
public String formatMessage(Locale locale, String key, Object[] arguments)
        throws MissingResourceException {

    if (fResourceBundle == null || locale != fLocale) {
        if (locale != null) {
            fResourceBundle = SecuritySupport.getResourceBundle(
                    "com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages", locale);
            // memorize the most-recent locale
            fLocale = locale;
        }
        if (fResourceBundle == null)
            fResourceBundle = SecuritySupport.getResourceBundle(
                    "com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages");
    }

    String msg = fResourceBundle.getString(key);
    if (arguments != null) {
        try {
            msg = java.text.MessageFormat.format(msg, arguments);
        } catch (Exception e) {
            msg = fResourceBundle.getString("FormatFailed");
            msg += " " + fResourceBundle.getString(key);
        }
    }

    if (msg == null) {
        msg = fResourceBundle.getString("BadMessageKey");
        throw new MissingResourceException(msg,
                "com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages", key);
    }

    return msg;
}
 
Example 10
Source File: XIncludeMessageFormatter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Formats a message with the specified arguments using the given
 * locale information.
 *
 * @param locale    The locale of the message.
 * @param key       The message key.
 * @param arguments The message replacement text arguments. The order
 *                  of the arguments must match that of the placeholders
 *                  in the actual message.
 *
 * @return Returns the formatted message.
 *
 * @throws MissingResourceException Thrown if the message with the
 *                                  specified key cannot be found.
 */
 public String formatMessage(Locale locale, String key, Object[] arguments)
    throws MissingResourceException {

    if (fResourceBundle == null || locale != fLocale) {
        if (locale != null) {
            fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages", locale);
            // memorize the most-recent locale
            fLocale = locale;
        }
        if (fResourceBundle == null)
            fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages");
    }

    String msg = fResourceBundle.getString(key);
    if (arguments != null) {
        try {
            msg = java.text.MessageFormat.format(msg, arguments);
        } catch (Exception e) {
            msg = fResourceBundle.getString("FormatFailed");
            msg += " " + fResourceBundle.getString(key);
        }
    }

    if (msg == null) {
        msg = fResourceBundle.getString("BadMessageKey");
        throw new MissingResourceException(msg, "com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages", key);
    }

    return msg;
}
 
Example 11
Source File: DOMMessageFormatter.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize Message Formatter.
 */
public static void init(){
    if (locale != null) {
        domResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.DOMMessages", locale);
        serResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSerializerMessages", locale);
        xmlResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
    }else{
        domResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.DOMMessages");
        serResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSerializerMessages");
        xmlResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
    }
}
 
Example 12
Source File: RegexParser.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void setLocale(Locale locale) {
    try {
        if (locale != null) {
            this.resources = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message", locale);
        }
        else {
            this.resources = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message");
        }
    }
    catch (MissingResourceException mre) {
        throw new RuntimeException("Installation Problem???  Couldn't load messages: "
                                   + mre.getMessage());
    }
}
 
Example 13
Source File: RegexParser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void setLocale(Locale locale) {
    try {
        if (locale != null) {
            this.resources = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message", locale);
        }
        else {
            this.resources = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message");
        }
    }
    catch (MissingResourceException mre) {
        throw new RuntimeException("Installation Problem???  Couldn't load messages: "
                                   + mre.getMessage());
    }
}
 
Example 14
Source File: DOMMessageFormatter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initialize Message Formatter.
 */
public static void init(){
    if (locale != null) {
        domResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.DOMMessages", locale);
        serResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSerializerMessages", locale);
        xmlResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
    }else{
        domResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.DOMMessages");
        serResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSerializerMessages");
        xmlResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
    }
}
 
Example 15
Source File: DOMMessageFormatter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initialize Message Formatter.
 */
public static void init(){
    if (locale != null) {
        domResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.DOMMessages", locale);
        serResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSerializerMessages", locale);
        xmlResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
    }else{
        domResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.DOMMessages");
        serResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSerializerMessages");
        xmlResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
    }
}
 
Example 16
Source File: XSMessageFormatter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Formats a message with the specified arguments using the given
 * locale information.
 *
 * @param locale    The locale of the message.
 * @param key       The message key.
 * @param arguments The message replacement text arguments. The order
 *                  of the arguments must match that of the placeholders
 *                  in the actual message.
 *
 * @return Returns the formatted message.
 *
 * @throws MissingResourceException Thrown if the message with the
 *                                  specified key cannot be found.
 */
 public String formatMessage(Locale locale, String key, Object[] arguments)
    throws MissingResourceException {

    if (fResourceBundle == null || locale != fLocale) {
        if (locale != null) {
            fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", locale);
            // memorize the most-recent locale
            fLocale = locale;
        }
        if (fResourceBundle == null)
            fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages");
    }

    String msg = fResourceBundle.getString(key);
    if (arguments != null) {
        try {
            msg = java.text.MessageFormat.format(msg, arguments);
        } catch (Exception e) {
            msg = fResourceBundle.getString("FormatFailed");
            msg += " " + fResourceBundle.getString(key);
        }
    }

    if (msg == null) {
        msg = fResourceBundle.getString("BadMessageKey");
        throw new MissingResourceException(msg, "com.sun.org.apache.xerces.internal.impl.msg.SchemaMessages", key);
    }

    return msg;
}
 
Example 17
Source File: XPointerMessageFormatter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Formats a message with the specified arguments using the given locale
 * information.
 *
 * @param locale
 *            The locale of the message.
 * @param key
 *            The message key.
 * @param arguments
 *            The message replacement text arguments. The order of the
 *            arguments must match that of the placeholders in the actual
 *            message.
 *
 * @return Returns the formatted message.
 *
 * @throws MissingResourceException
 *             Thrown if the message with the specified key cannot be found.
 */
public String formatMessage(Locale locale, String key, Object[] arguments)
        throws MissingResourceException {

    if (fResourceBundle == null || locale != fLocale) {
        if (locale != null) {
            fResourceBundle = SecuritySupport.getResourceBundle(
                    "com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages", locale);
            // memorize the most-recent locale
            fLocale = locale;
        }
        if (fResourceBundle == null)
            fResourceBundle = SecuritySupport.getResourceBundle(
                    "com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages");
    }

    String msg = fResourceBundle.getString(key);
    if (arguments != null) {
        try {
            msg = java.text.MessageFormat.format(msg, arguments);
        } catch (Exception e) {
            msg = fResourceBundle.getString("FormatFailed");
            msg += " " + fResourceBundle.getString(key);
        }
    }

    if (msg == null) {
        msg = fResourceBundle.getString("BadMessageKey");
        throw new MissingResourceException(msg,
                "com.sun.org.apache.xerces.internal.impl.msg.XPointerMessages", key);
    }

    return msg;
}
 
Example 18
Source File: RegexParser.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public void setLocale(Locale locale) {
    try {
        if (locale != null) {
            this.resources = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message", locale);
        }
        else {
            this.resources = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message");
        }
    }
    catch (MissingResourceException mre) {
        throw new RuntimeException("Installation Problem???  Couldn't load messages: "
                                   + mre.getMessage());
    }
}
 
Example 19
Source File: DOMMessageFormatter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initialize Message Formatter.
 */
public static void init(){
    if (locale != null) {
        domResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.DOMMessages", locale);
        serResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSerializerMessages", locale);
        xmlResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", locale);
    }else{
        domResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.DOMMessages");
        serResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSerializerMessages");
        xmlResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
    }
}
 
Example 20
Source File: XIncludeMessageFormatter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Formats a message with the specified arguments using the given
 * locale information.
 *
 * @param locale    The locale of the message.
 * @param key       The message key.
 * @param arguments The message replacement text arguments. The order
 *                  of the arguments must match that of the placeholders
 *                  in the actual message.
 *
 * @return Returns the formatted message.
 *
 * @throws MissingResourceException Thrown if the message with the
 *                                  specified key cannot be found.
 */
 public String formatMessage(Locale locale, String key, Object[] arguments)
    throws MissingResourceException {

    if (fResourceBundle == null || locale != fLocale) {
        if (locale != null) {
            fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages", locale);
            // memorize the most-recent locale
            fLocale = locale;
        }
        if (fResourceBundle == null)
            fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages");
    }

    String msg = fResourceBundle.getString(key);
    if (arguments != null) {
        try {
            msg = java.text.MessageFormat.format(msg, arguments);
        } catch (Exception e) {
            msg = fResourceBundle.getString("FormatFailed");
            msg += " " + fResourceBundle.getString(key);
        }
    }

    if (msg == null) {
        msg = fResourceBundle.getString("BadMessageKey");
        throw new MissingResourceException(msg, "com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages", key);
    }

    return msg;
}