src/java.xml/share/classes/javax/xml/catalog/CatalogMessages.java
author thartmann
Fri, 24 Aug 2018 08:17:23 +0200
changeset 51514 1e332d63bd96
parent 50783 0ed32e0d98e1
permissions -rw-r--r--
8209833: C2 compilation fails with "assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place" Summary: Deoptimize if exception is thrown in _clone intrinsic. Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     1
/*
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 33542
diff changeset
     2
 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     4
 *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    10
 *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    15
 * accompanied this code).
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    16
 *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    20
 *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    23
 * questions.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    24
 */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    25
package javax.xml.catalog;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    26
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 33542
diff changeset
    27
import java.net.URI;
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    28
import java.util.Locale;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    29
import java.util.MissingResourceException;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    30
import java.util.ResourceBundle;
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 33542
diff changeset
    31
import jdk.xml.internal.SecuritySupport;
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    32
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    33
/**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    34
 * Catalog Error messages
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    35
 *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    36
 * @since 9
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    37
 */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    38
final class CatalogMessages {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    39
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    40
    public static final String ERR_INVALID_CATALOG = "InvalidCatalog";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    41
    public static final String ERR_INVALID_ENTRY_TYPE = "InvalidEntryType";
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 33542
diff changeset
    42
    public static final String ERR_URI_NOTABSOLUTE = "UriNotAbsolute";
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 33542
diff changeset
    43
    public static final String ERR_URI_NOTVALIDURL = "UriNotValidUrl";
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    44
    public static final String ERR_INVALID_ARGUMENT = "InvalidArgument";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    45
    public static final String ERR_NULL_ARGUMENT = "NullArgument";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    46
    public static final String ERR_CIRCULAR_REFERENCE = "CircularReference";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    47
    public static final String ERR_INVALID_PATH = "InvalidPath";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    48
    public static final String ERR_PARSER_CONF = "ParserConf";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    49
    public static final String ERR_PARSING_FAILED = "ParsingFailed";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    50
    public static final String ERR_NO_CATALOG = "NoCatalogFound";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    51
    public static final String ERR_NO_MATCH = "NoMatchFound";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    52
    public static final String ERR_NO_URI_MATCH = "NoMatchURIFound";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    53
    public static final String ERR_CREATING_URI = "FailedCreatingURI";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    54
    public static final String ERR_OTHER = "OtherError";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    55
50783
0ed32e0d98e1 8205623: Replace use of Class::getPackage with Class::getPackageName
mchung
parents: 47216
diff changeset
    56
    static final String bundleName = CatalogMessages.class.getPackageName() + ".CatalogMessages";
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    57
    static ResourceBundle resourceBundle;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    58
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    59
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    60
     * Reports an error.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    61
     * @param key the message key
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    62
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    63
    static void reportError(String key) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    64
        reportError(key, null);
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    65
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    66
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    67
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    68
     * Reports an error.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    69
     * @param key the message key
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    70
     * @param arguments the message replacement text arguments. The order of the
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    71
     * arguments must match that of the placeholders in the actual message.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    72
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    73
    static void reportError(String key, Object[] arguments) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    74
        throw new CatalogException(formatMessage(key, arguments));
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    75
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    76
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    77
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    78
     * Reports a CatalogException.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    79
     * @param key the message key
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    80
     * @param arguments the message replacement text arguments. The order of the
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    81
     * arguments must match that of the placeholders in the actual message.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    82
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    83
    static void reportRunTimeError(String key, Object[] arguments) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    84
        throw new CatalogException(formatMessage(key, arguments));
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    85
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    86
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    87
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    88
     * Reports a CatalogException.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    89
     * @param  key the message key
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    90
     * @param cause the cause if any
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    91
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    92
    static void reportRunTimeError(String key, Throwable cause) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    93
        throw new CatalogException(formatMessage(key, null), cause);
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    94
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    95
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    96
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    97
     * Reports a CatalogException.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    98
     * @param  key the message key
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    99
     * @param arguments the message replacement text arguments. The order of the
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   100
     * arguments must match that of the placeholders in the actual message.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   101
     * @param cause the cause if any
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   102
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   103
    static void reportRunTimeError(String key, Object[] arguments, Throwable cause) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   104
        throw new CatalogException(formatMessage(key, arguments), cause);
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   105
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   106
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   107
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   108
     * Reports IllegalArgumentException if the argument is null.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   109
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   110
     * @param name the name of the argument
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   111
     * @param value the value of the argument
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   112
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   113
    static void reportIAEOnNull(String name, String value) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   114
        if (value == null) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   115
            throw new IllegalArgumentException(
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   116
                    formatMessage(ERR_INVALID_ARGUMENT, new Object[]{null, name}));
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   117
        }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   118
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   119
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   120
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   121
     * Reports NullPointerException if the argument is null.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   122
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   123
     * @param name the name of the argument
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   124
     * @param value the value of the argument
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   125
     */
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 33542
diff changeset
   126
    static void reportNPEOnNull(String name, Object value) {
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   127
        if (value == null) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   128
            throw new NullPointerException(
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   129
                    formatMessage(ERR_NULL_ARGUMENT, new Object[]{name}));
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   130
        }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   131
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   132
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   133
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   134
     * Reports IllegalArgumentException
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   135
     * @param arguments the arguments for formating the error message
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   136
     * @param cause the cause if any
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   137
     */
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 33542
diff changeset
   138
    static void reportIAE(String key, Object[] arguments, Throwable cause) {
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   139
        throw new IllegalArgumentException(
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 33542
diff changeset
   140
                formatMessage(key, arguments), cause);
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   141
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   142
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   143
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   144
     * Format a message with the specified arguments using the default locale
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   145
     * information.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   146
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   147
     * @param key the message key
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   148
     * @param arguments the message replacement text arguments. The order of the
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   149
     * arguments must match that of the placeholders in the actual message.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   150
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   151
     * @return the formatted message
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   152
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   153
     * @throws MissingResourceException If the message with the specified key
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   154
     * cannot be found
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   155
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   156
    static String formatMessage(String key, Object[] arguments) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   157
        return formatMessage(key, arguments, Locale.getDefault());
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   158
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   159
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   160
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   161
     * Format a message with the specified arguments using the given locale
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   162
     * information.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   163
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   164
     * @param key the message key
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   165
     * @param arguments the message replacement text arguments. The order of the
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   166
     * arguments must match that of the placeholders in the actual message.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   167
     * @param locale the locale of the message
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   168
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   169
     * @return the formatted message
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   170
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   171
     * @throws MissingResourceException If the message with the specified key
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   172
     * cannot be found
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   173
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   174
    static String formatMessage(String key, Object[] arguments, Locale locale) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   175
        return SecuritySupport.getErrorMessage(locale, bundleName, key, arguments);
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   176
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   177
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   178
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   179
     * Returns sanitized URI.
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 33542
diff changeset
   180
     * @param uri a URI to be sanitized
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   181
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   182
    static String sanitize(String uri) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   183
        if (uri == null) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   184
            return null;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   185
        }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   186
        String temp;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   187
        int p;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   188
        p = uri.lastIndexOf("/");
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   189
        if (p > 0 && p < uri.length()) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   190
            return uri.substring(p + 1);
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   191
        }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   192
        return uri;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   193
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   194
}