jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java
author alexsch
Tue, 17 Nov 2015 19:09:37 +0400
changeset 34401 5c29353d768b
parent 33542 9f0eef87e8c1
child 34984 48a409c654e9
permissions -rw-r--r--
7124218: Space should select cell in the JTable Reviewed-by: rchamyal, alexsch Contributed-by: Avik Niyogi <avik.niyogi@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     1
/*
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
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
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    27
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    28
/**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    29
 * The Catalog Manager manages the creation of XML Catalogs and Catalog Resolvers.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    30
 *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    31
 * @since 9
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
public final class CatalogManager {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    34
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    35
     * Creating CatalogManager instance is not allowed.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    36
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    37
    private CatalogManager() {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    38
    }
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
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    41
     * Creates a Catalog object using the specified feature settings and path to
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    42
     * a catalog file. If the features is null, the default features will be used.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    43
     * If the path is empty, System property {@code javax.xml.catalog.files} will
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    44
     * be read to locate the initial list of catalog files.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    45
     * <p>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    46
     * If more than one catalog files are specified through the path argument or
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    47
     * {@code javax.xml.catalog.files} property, the first entry is considered
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    48
     * the main catalog, while others are treated as alternative catalogs after
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    49
     * those referenced by the {@code nextCatalog} elements in the main catalog.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    50
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    51
     * @param features the catalog features
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    52
     * @param path path(s) to one or more catalogs.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    53
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    54
     * @return a catalog instance
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    55
     * @throws CatalogException If no catalog can be found whether through the
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    56
     * specified path or the System property {@code javax.xml.catalog.files}, or
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    57
     * an error occurs while parsing the catalog
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
    public static Catalog catalog(CatalogFeatures features, String... path) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    60
        return new CatalogImpl(features, path);
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    61
    }
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
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    64
     * Creates an instance of a CatalogResolver using the specified catalog.
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
     * @param catalog the catalog instance
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    67
     * @return an instance of a CatalogResolver
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    68
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    69
    public static CatalogResolver catalogResolver(Catalog catalog) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    70
        if (catalog == null) CatalogMessages.reportNPEOnNull("catalog", null);
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    71
        return new CatalogResolverImpl(catalog);
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
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    74
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    75
     * Creates an instance of a CatalogUriResolver using the specified catalog.
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
     * @param catalog the catalog instance
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    78
     * @return an instance of a CatalogResolver
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    79
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    80
    public static CatalogUriResolver catalogUriResolver(Catalog catalog) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    81
        if (catalog == null) CatalogMessages.reportNPEOnNull("catalog", null);
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    82
        return new CatalogUriResolverImpl(catalog);
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    83
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    84
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
     * Creates an instance of a CatalogResolver using the specified feature settings
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    87
     * and path to a catalog file. If the features is null, the default features will
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    88
     * be used. If the path is empty, System property {@code javax.xml.catalog.files}
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    89
     * will be read to locate the initial list of catalog files.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    90
     * <p>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    91
     * If more than one catalog files are specified through the path argument or
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    92
     * {@code javax.xml.catalog.files} property, the first entry is considered
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    93
     * the main catalog, while others are treated as alternative catalogs after
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    94
     * those referenced by the {@code nextCatalog} elements in the main catalog.
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
     * @param features the catalog features
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    97
     * @param path the path(s) to one or more catalogs
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    98
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    99
     * @return an instance of a CatalogResolver
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   100
     * @throws CatalogException If no catalog can be found whether through the
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   101
     * specified path or the System property {@code javax.xml.catalog.files}, or
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   102
     * an error occurs while parsing the catalog
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   103
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   104
    public static CatalogResolver catalogResolver(CatalogFeatures features, String... path) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   105
        Catalog catalog = catalog(features, path);
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   106
        return new CatalogResolverImpl(catalog);
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
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
     * Creates an instance of a CatalogUriResolver using the specified feature settings
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   111
     * and path to a catalog file. If the features is null, the default features will
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   112
     * be used. If the path is empty, System property {@code javax.xml.catalog.files}
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   113
     * will be read to locate the initial list of catalog files.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   114
     * <p>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   115
     * If more than one catalog files are specified through the path argument or
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   116
     * {@code javax.xml.catalog.files} property, the first entry is considered
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   117
     * the main catalog, while others are treated as alternative catalogs after
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   118
     * those referenced by the {@code nextCatalog} elements in the main catalog.
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
     * @param features the catalog features
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   121
     * @param path the path(s) to one or more catalogs
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
     * @return an instance of a CatalogResolver
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   124
     * @throws CatalogException If no catalog can be found whether through the
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   125
     * specified path or the System property {@code javax.xml.catalog.files}, or
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   126
     * an error occurs while parsing the catalog
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   127
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   128
    public static CatalogUriResolver catalogUriResolver(CatalogFeatures features, String... path) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   129
        Catalog catalog = catalog(features, path);
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   130
        return new CatalogUriResolverImpl(catalog);
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
}