jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogFeatures.java
author jjg
Tue, 16 May 2017 17:36:12 -0700
changeset 45261 8a151bf73222
parent 43121 e73af7b6ce47
child 45855 46c3f654e80f
permissions -rw-r--r--
8180385: Fix HTML5 issues in the java.xml module Reviewed-by: joehw, lancea
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: 39907
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
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
    27
import java.net.MalformedURLException;
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
    28
import java.net.URISyntaxException;
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
    29
import java.util.HashMap;
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
    30
import java.util.Map;
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    31
import jdk.xml.internal.SecuritySupport;
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
 * The CatalogFeatures holds a collection of features and properties.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    35
 * <p>
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
 *
45261
8a151bf73222 8180385: Fix HTML5 issues in the java.xml module
jjg
parents: 43121
diff changeset
    38
 * <table class="plain">
8a151bf73222 8180385: Fix HTML5 issues in the java.xml module
jjg
parents: 43121
diff changeset
    39
 * <caption>Catalog Features</caption>
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    40
 * <thead>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    41
 * <tr>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    42
 * <th rowspan="2">Feature</th>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    43
 * <th rowspan="2">Description</th>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    44
 * <th rowspan="2">Property Name</th>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    45
 * <th rowspan="2">System Property [1]</th>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    46
 * <th rowspan="2">jaxp.properties [1]</th>
45261
8a151bf73222 8180385: Fix HTML5 issues in the java.xml module
jjg
parents: 43121
diff changeset
    47
 * <th colspan="2" style="text-align:center">Value [2]</th>
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    48
 * <th rowspan="2">Action</th>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    49
 * </tr>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    50
 * <tr>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    51
 * <th>Type</th>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    52
 * <th>Value</th>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    53
 * </tr>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    54
 * </thead>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    55
 * <tbody>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    56
 *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    57
 * <tr>
45261
8a151bf73222 8180385: Fix HTML5 issues in the java.xml module
jjg
parents: 43121
diff changeset
    58
 * <td><a id="FILES">FILES</a></td>
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
    59
 * <td>A semicolon-delimited list of URIs to locate the catalog files.
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
    60
 * The URIs must be absolute and have a URL protocol handler for the URI scheme.
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    61
 * </td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    62
 * <td>javax.xml.catalog.files</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    63
 * <td>javax.xml.catalog.files</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    64
 * <td>javax.xml.catalog.files</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    65
 * <td>String</td>
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
    66
 * <td>URIs</td>
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    67
 * <td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    68
 * Reads the first catalog as the current catalog; Loads others if no match
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    69
 * is found in the current catalog including delegate catalogs if any.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    70
 * </td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    71
 * </tr>
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
 * <tr>
45261
8a151bf73222 8180385: Fix HTML5 issues in the java.xml module
jjg
parents: 43121
diff changeset
    74
 * <td rowspan="2"><a id="PREFER">PREFER</a></td>
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    75
 * <td rowspan="2">Indicates the preference between the public and system
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    76
 * identifiers. The default value is public [3].</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    77
 * <td rowspan="2">javax.xml.catalog.prefer</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    78
 * <td rowspan="2">N/A</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    79
 * <td rowspan="2">N/A</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    80
 * <td rowspan="2">String</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    81
 * <td>{@code system}</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    82
 * <td>Searches system entries for a match; Searches public entries when
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    83
 * external identifier specifies only a public identifier</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    84
 * </tr>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    85
 * <tr>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    86
 * <td>{@code public}</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    87
 * <td>Searches system entries for a match; Searches public entries when
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    88
 * there is no matching system entry.</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    89
 * </tr>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    90
 *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    91
 * <tr>
45261
8a151bf73222 8180385: Fix HTML5 issues in the java.xml module
jjg
parents: 43121
diff changeset
    92
 * <td rowspan="2"><a id="DEFER">DEFER</a></td>
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    93
 * <td rowspan="2">Indicates that the alternative catalogs including those
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    94
 * specified in delegate entries or nextCatalog are not read until they are
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    95
 * needed. The default value is true.</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    96
 * <td rowspan="2">javax.xml.catalog.defer [4]</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    97
 * <td rowspan="2">javax.xml.catalog.defer</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    98
 * <td rowspan="2">javax.xml.catalog.defer</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
    99
 * <td rowspan="2">String</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   100
 * <td>{@code true}</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   101
 * <td>Loads alternative catalogs as needed.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   102
 * </td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   103
 * </tr>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   104
 * <tr>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   105
 * <td>{@code false}</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   106
 * <td>Loads all catalogs[5]. </td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   107
 * </tr>
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
 * <tr>
45261
8a151bf73222 8180385: Fix HTML5 issues in the java.xml module
jjg
parents: 43121
diff changeset
   110
 * <td rowspan="3"><a id="RESOLVE">RESOLVE</a></td>
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   111
 * <td rowspan="3">Determines the action if there is no matching entry found after
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   112
 * all of the specified catalogs are exhausted. The default is strict.</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   113
 * <td rowspan="3">javax.xml.catalog.resolve [4]</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   114
 * <td rowspan="3">javax.xml.catalog.resolve</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   115
 * <td rowspan="3">javax.xml.catalog.resolve</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   116
 * <td rowspan="3">String</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   117
 * <td>{@code strict}</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   118
 * <td>Throws CatalogException if there is no match.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   119
 * </td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   120
 * </tr>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   121
 * <tr>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   122
 * <td>{@code continue}</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   123
 * <td>Allows the XML parser to continue as if there is no match.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   124
 * </td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   125
 * </tr>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   126
 * <tr>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   127
 * <td>{@code ignore}</td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   128
 * <td>Tells the XML parser to skip the external references if there no match.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   129
 * </td>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   130
 * </tr>
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
 * </tbody>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   133
 * </table>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   134
 * <p>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   135
 * <b>[1]</b> There is no System property for the features that marked as "N/A".
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   136
 *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   137
 * <p>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   138
 * <b>[2]</b> The value shall be exactly as listed in this table, case-sensitive.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   139
 * Any unspecified value will result in {@link IllegalArgumentException}.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   140
 * <p>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   141
 * <b>[3]</b> The Catalog specification defined complex rules on
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   142
 * <a href="https://www.oasis-open.org/committees/download.php/14809/xml-catalogs.html#attrib.prefer">
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   143
 * the prefer attribute</a>. Although the prefer can be public or system, the
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   144
 * specification actually made system the preferred option, that is, no matter
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   145
 * the option, a system entry is always used if found. Public entries are only
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   146
 * considered if the prefer is public and system entries are not found. It is
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   147
 * therefore recommended that the prefer attribute be set as public
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   148
 * (which is the default).
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   149
 * <p>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   150
 * <b>[4]</b> Although non-standard attributes in the OASIS Catalog specification,
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   151
 * {@code defer} and {@code resolve} are recognized by the Java Catalog API the
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   152
 * same as the {@code prefer} as being an attribute in the catalog entry of the
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   153
 * main catalog. Note that only the attributes specified for the catalog entry
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   154
 * of the main Catalog file will be used.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   155
  * <p>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   156
 * <b>[5]</b> If the intention is to share an entire catalog store, it may be desirable to
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   157
 * set the property {@code javax.xml.catalog.defer} to false to allow the entire
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   158
 * catalog to be pre-loaded.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   159
 * <p>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   160
 * <h3>Scope and Order</h3>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   161
 * Features and properties can be set through the catalog file, the Catalog API,
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   162
 * system properties, and {@code jaxp.properties}, with a preference in the same order.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   163
 * <p>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   164
 * Properties that are specified as attributes in the catalog file for the
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   165
 * catalog and group entries shall take preference over any of the other settings.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   166
 * For example, if a {@code prefer} attribute is set in the catalog file as in
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   167
 * {@code <catalog prefer="public">}, any other input for the "prefer" property
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   168
 * is not necessary or will be ignored.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   169
 * <p>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   170
 * Properties set through the Catalog API override those that may have been set
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   171
 * by system properties and/or in {@code jaxp.properties}. In case of multiple
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   172
 * interfaces, the latest in a procedure shall take preference. For
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
   173
 * {@link Feature#FILES}, this means that the URI(s) specified through the methods
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   174
 * of the {@link CatalogManager} will override any that may have been entered
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   175
 * through the {@link Builder}.
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
 * <p>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   178
 * System properties when set shall override those in {@code jaxp.properties}.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   179
 * <p>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   180
 * The {@code jaxp.properties} file is typically in the conf directory of the Java
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   181
 * installation. The file is read only once by the JAXP implementation and
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   182
 * its values are then cached for future use. If the file does not exist
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   183
 * when the first attempt is made to read from it, no further attempts are
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   184
 * made to check for its existence. It is not possible to change the value
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   185
 * of any properties in {@code jaxp.properties} after it has been read.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   186
 * <p>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   187
 * A CatalogFeatures instance can be created through its builder as illustrated
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   188
 * in the following sample code:
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   189
 * <pre>{@code
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   190
                CatalogFeatures f = CatalogFeatures.builder()
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
   191
                        .with(Feature.FILES, "file:///etc/xml/catalog")
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   192
                        .with(Feature.PREFER, "public")
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   193
                        .with(Feature.DEFER, "true")
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   194
                        .with(Feature.RESOLVE, "ignore")
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   195
                        .build();
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   196
 * }</pre>
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   197
 *
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   198
 * <p>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   199
 * <h3>JAXP XML Processor Support</h3>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   200
 * The Catalog Features are supported throughout the JAXP processors, including
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   201
 * SAX and DOM ({@link javax.xml.parsers}), and StAX parsers ({@link javax.xml.stream}),
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   202
 * Schema Validation ({@link javax.xml.validation}), and XML Transformation
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   203
 * ({@link javax.xml.transform}). The features described above can be set through JAXP
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   204
 * factories or processors that define a setProperty or setAttribute interface.
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
   205
 * For example, the following code snippet sets a URI to a catalog file on a SAX
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   206
 * parser through the {@code javax.xml.catalog.files} property:
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   207
 * <p>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   208
 * <pre>{@code
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   209
 *      SAXParserFactory spf = SAXParserFactory.newInstance();
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   210
 *      spf.setFeature(XMLConstants.USE_CATALOG, true); [1]
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   211
 *      SAXParser parser = spf.newSAXParser();
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
   212
 *      parser.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), "file:///etc/xml/catalog");
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   213
 * }</pre>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   214
 * <p>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   215
 * [1] Note that this statement is not required since the default value of
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   216
 * {@link javax.xml.XMLConstants#USE_CATALOG USE_CATALOG} is true.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   217
 *
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   218
 * <p>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   219
 * The JAXP Processors' support for Catalog depends on both the
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   220
 * {@link javax.xml.XMLConstants#USE_CATALOG USE_CATALOG} feature and the
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   221
 * existence of valid Catalog file(s). A JAXP processor will use the Catalog
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   222
 * only when the feature is true and valid Catalog file(s) are specified through
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   223
 * the {@code javax.xml.catalog.files} property. It will make no attempt to use
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   224
 * the Catalog if either {@link javax.xml.XMLConstants#USE_CATALOG USE_CATALOG}
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   225
 * is set to false, or there is no Catalog file specified.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   226
 *
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   227
 * <p>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   228
 * The JAXP processors will observe the default settings of the
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   229
 * {@link javax.xml.catalog.CatalogFeatures}. The processors, for example, will
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   230
 * report an Exception by default when no matching entry is found since the
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   231
 * default value of the {@code javax.xml.catalog.resolve} property is strict.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   232
 *
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   233
 * <p>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   234
 * The JAXP processors give preference to user-specified custom resolvers. If such
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   235
 * a resolver is registered, it will be used over the CatalogResolver. If it returns
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   236
 * null however, the processors will continue resolving with the CatalogResolver.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   237
 * If it returns an empty source, no attempt will be made by the CatalogResolver.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   238
 *
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   239
 * <p>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   240
 * The Catalog support is available for any process in the JAXP library that
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   241
 * supports a resolver. The following table lists all such processes.
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   242
 *
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   243
 * <p>
45261
8a151bf73222 8180385: Fix HTML5 issues in the java.xml module
jjg
parents: 43121
diff changeset
   244
 * <h3><a id="ProcessesWithCatalogSupport">Processes with Catalog Support</a></h3>
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   245
 *
45261
8a151bf73222 8180385: Fix HTML5 issues in the java.xml module
jjg
parents: 43121
diff changeset
   246
 * <table class="striped">
8a151bf73222 8180385: Fix HTML5 issues in the java.xml module
jjg
parents: 43121
diff changeset
   247
 * <caption>Processes with Catalog Support</caption>
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   248
 * <thead>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   249
 * <tr>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   250
 * <th>Process</th>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   251
 * <th>Catalog Entry Type</th>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   252
 * <th>Example</th>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   253
 * </tr>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   254
 * </thead>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   255
 * <tbody>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   256
 * <tr>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   257
 * <td>DTDs and external entities</td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   258
 * <td>public, system</td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   259
 * <td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   260
 * <pre>{@literal
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   261
   The following DTD reference:
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   262
   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   263
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   264
   Can be resolved using the following Catalog entry:
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   265
   <public publicId="-//W3C//DTD XHTML 1.0 Strict//EN" uri="catalog/xhtml1-strict.dtd"/>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   266
   or
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   267
   <systemSuffix systemIdSuffix="html1-strict.dtd" uri="catalog/xhtml1-strict.dtd"/>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   268
 * }</pre>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   269
 * </td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   270
 * </tr>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   271
 * <tr>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   272
 * <td>XInclude</td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   273
 * <td>uri</td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   274
 * <td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   275
 * <pre>{@literal
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   276
   The following XInclude element:
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   277
   <xi:include href="http://openjdk.java.net/xml/disclaimer.xml"/>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   278
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
   279
   can be resolved using a URI entry:
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   280
   <uri name="http://openjdk.java.net/xml/disclaimer.xml" uri="file:///pathto/local/disclaimer.xml"/>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   281
   or
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   282
   <uriSuffix uriSuffix="disclaimer.xml" uri="file:///pathto/local/disclaimer.xml"/>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   283
 * }</pre>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   284
 * </td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   285
 * </tr>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   286
 * <tr>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   287
 * <td>XSD import</td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   288
 * <td>uri</td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   289
 * <td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   290
 * <pre>{@literal
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   291
   The following import element:
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   292
    <xsd:import namespace="http://openjdk.java.net/xsd/XSDImport_person"
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   293
                schemaLocation="http://openjdk.java.net/xsd/XSDImport_person.xsd"/>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   294
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
   295
   can be resolved using a URI entry:
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   296
   <uri name="http://openjdk.java.net/xsd/XSDImport_person.xsd" uri="file:///pathto/local/XSDImport_person.xsd"/>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   297
   or
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   298
   <uriSuffix uriSuffix="XSDImport_person.xsd" uri="file:///pathto/local/XSDImport_person.xsd"/>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   299
   or
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   300
   <uriSuffix uriSuffix="http://openjdk.java.net/xsd/XSDImport_person" uri="file:///pathto/local/XSDImport_person.xsd"/>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   301
 * }</pre>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   302
 * </td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   303
 * </tr>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   304
 * <tr>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   305
 * <td>XSD include</td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   306
 * <td>uri</td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   307
 * <td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   308
 * <pre>{@literal
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   309
   The following include element:
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   310
   <xsd:include schemaLocation="http://openjdk.java.net/xsd/XSDInclude_person.xsd"/>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   311
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
   312
   can be resolved using a URI entry:
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   313
   <uri name="http://openjdk.java.net/xsd/XSDInclude_person.xsd" uri="file:///pathto/local/XSDInclude_person.xsd"/>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   314
   or
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   315
   <uriSuffix uriSuffix="XSDInclude_person.xsd" uri="file:///pathto/local/XSDInclude_person.xsd"/>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   316
 * }</pre>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   317
 * </td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   318
 * </tr>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   319
 * <tr>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   320
 * <td>XSL import and include</td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   321
 * <td>uri</td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   322
 * <td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   323
 * <pre>{@literal
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   324
   The following include element:
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   325
   <xsl:include href="http://openjdk.java.net/xsl/include.xsl"/>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   326
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
   327
   can be resolved using a URI entry:
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   328
   <uri name="http://openjdk.java.net/xsl/include.xsl" uri="file:///pathto/local/include.xsl"/>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   329
   or
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   330
   <uriSuffix uriSuffix="include.xsl" uri="file:///pathto/local/include.xsl"/>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   331
 * }</pre>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   332
 * </td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   333
 * </tr>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   334
 * <tr>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   335
 * <td>XSL document function</td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   336
 * <td>uri</td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   337
 * <td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   338
 * <pre>{@literal
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   339
   The document in the following element:
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   340
   <xsl:variable name="dummy" select="document('http://openjdk.java.net/xsl/list.xml')"/>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   341
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
   342
   can be resolved using a URI entry:
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   343
   <uri name="http://openjdk.java.net/xsl/list.xml" uri="file:///pathto/local/list.xml"/>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   344
   or
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   345
   <uriSuffix uriSuffix="list.xml" uri="file:///pathto/local/list.xml"/>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   346
 * }</pre>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   347
 * </td>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   348
 * </tr>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   349
 * </tbody>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   350
 * </table>
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   351
 *
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   352
 * @since 9
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   353
 */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   354
public class CatalogFeatures {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   355
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   356
    /**
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   357
     * The constant name of the javax.xml.catalog.files property as described
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   358
     * in the property table above.
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   359
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   360
    static final String CATALOG_FILES = "javax.xml.catalog.files";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   361
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   362
    /**
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   363
     * The javax.xml.catalog.prefer property as described
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   364
     * in the property table above.
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   365
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   366
    static final String CATALOG_PREFER = "javax.xml.catalog.prefer";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   367
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   368
    /**
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   369
     * The javax.xml.catalog.defer property as described
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   370
     * in the property table above.
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   371
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   372
    static final String CATALOG_DEFER = "javax.xml.catalog.defer";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   373
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   374
    /**
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   375
     * The javax.xml.catalog.resolve property as described
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   376
     * in the property table above.
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   377
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   378
    static final String CATALOG_RESOLVE = "javax.xml.catalog.resolve";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   379
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   380
    //values for the prefer property
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   381
    static final String PREFER_SYSTEM = "system";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   382
    static final String PREFER_PUBLIC = "public";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   383
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   384
    //values for the defer property
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   385
    static final String DEFER_TRUE = "true";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   386
    static final String DEFER_FALSE = "false";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   387
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   388
    //values for the Resolve property
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   389
    static final String RESOLVE_STRICT = "strict";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   390
    static final String RESOLVE_CONTINUE = "continue";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   391
    static final String RESOLVE_IGNORE = "ignore";
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   392
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   393
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   394
     * A Feature type as defined in the
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   395
     * <a href="CatalogFeatures.html#CatalogFeatures">Catalog Features table</a>.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   396
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   397
    public static enum Feature {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   398
        /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   399
         * The {@code javax.xml.catalog.files} property as described in
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   400
         * item <a href="CatalogFeatures.html#FILES">FILES</a> of the
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   401
         * Catalog Features table.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   402
         */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   403
        FILES(CATALOG_FILES, null, true),
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   404
        /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   405
         * The {@code javax.xml.catalog.prefer} property as described in
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   406
         * item <a href="CatalogFeatures.html#PREFER">PREFER</a> of the
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   407
         * Catalog Features table.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   408
         */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   409
        PREFER(CATALOG_PREFER, PREFER_PUBLIC, false),
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   410
        /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   411
         * The {@code javax.xml.catalog.defer} property as described in
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   412
         * item <a href="CatalogFeatures.html#DEFER">DEFER</a> of the
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   413
         * Catalog Features table.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   414
         */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   415
        DEFER(CATALOG_DEFER, DEFER_TRUE, true),
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   416
        /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   417
         * The {@code javax.xml.catalog.resolve} property as described in
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   418
         * item <a href="CatalogFeatures.html#RESOLVE">RESOLVE</a> of the
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   419
         * Catalog Features table.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   420
         */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   421
        RESOLVE(CATALOG_RESOLVE, RESOLVE_STRICT, true);
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   422
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   423
        private final String name;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   424
        private final String defaultValue;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   425
        private String value;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   426
        private final boolean hasSystem;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   427
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   428
        /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   429
         * Constructs a CatalogFeature instance.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   430
         * @param name the name of the feature
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   431
         * @param value the value of the feature
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   432
         * @param hasSystem a flag to indicate whether the feature is supported
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   433
         * with a System property
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   434
         */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   435
        Feature(String name, String value, boolean hasSystem) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   436
            this.name = name;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   437
            this.defaultValue = value;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   438
            this.hasSystem = hasSystem;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   439
        }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   440
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   441
        /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   442
         * Checks whether the specified property is equal to the current property.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   443
         * @param propertyName the name of a property
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   444
         * @return true if the specified property is the current property, false
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   445
         * otherwise
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   446
         */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   447
        boolean equalsPropertyName(String propertyName) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   448
            return name.equals(propertyName);
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   449
        }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   450
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   451
        /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   452
         * Returns the name of the corresponding System Property.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   453
         *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   454
         * @return the name of the System Property
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   455
         */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   456
        public String getPropertyName() {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   457
            return name;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   458
        }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   459
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   460
        /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   461
         * Returns the default value of the property.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   462
         * @return the default value of the property
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   463
         */
39907
db51759e3695 8158084: Catalog API: JAXP XML Processor Support
joehw
parents: 37737
diff changeset
   464
        public String defaultValue() {
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   465
            return defaultValue;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   466
        }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   467
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   468
        /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   469
         * Returns the value of the property.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   470
         * @return the value of the property
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   471
         */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   472
        String getValue() {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   473
            return value;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   474
        }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   475
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   476
        /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   477
         * Checks whether System property is supported for the feature.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   478
         * @return true it is supported, false otherwise
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   479
         */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   480
        boolean hasSystemProperty() {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   481
            return hasSystem;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   482
        }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   483
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   484
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   485
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   486
     * States of the settings of a property, in the order: default value,
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   487
     * jaxp.properties file, jaxp system properties, and jaxp api properties
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   488
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   489
    static enum State {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   490
        /** represents the default state of a feature. */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   491
        DEFAULT("default"),
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   492
        /** indicates the value of the feature is read from jaxp.properties. */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   493
        JAXPDOTPROPERTIES("jaxp.properties"),
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   494
        /** indicates the value of the feature is read from its System property. */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   495
        SYSTEMPROPERTY("system property"),
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   496
        /** indicates the value of the feature is specified through the API. */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   497
        APIPROPERTY("property"),
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   498
        /** indicates the value of the feature is specified as a catalog attribute. */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   499
        CATALOGATTRIBUTE("catalog attribute");
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   500
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   501
        final String literal;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   502
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   503
        State(String literal) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   504
            this.literal = literal;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   505
        }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   506
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   507
        String literal() {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   508
            return literal;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   509
        }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   510
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   511
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   512
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   513
     * Values of the properties
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   514
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   515
    private String[] values;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   516
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   517
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   518
     * States of the settings for each property
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   519
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   520
    private State[] states;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   521
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   522
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   523
     * Private class constructor
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   524
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   525
    private CatalogFeatures() {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   526
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   527
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   528
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   529
     * Returns a CatalogFeatures instance with default settings.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   530
     * @return a default CatalogFeatures instance
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   531
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   532
    public static CatalogFeatures defaults() {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   533
        return CatalogFeatures.builder().build();
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   534
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   535
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   536
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   537
     * Constructs a new CatalogFeatures instance with the builder.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   538
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   539
     * @param builder the builder to build the CatalogFeatures
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   540
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   541
    CatalogFeatures(Builder builder) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   542
        init();
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   543
        setProperties(builder);
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   544
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   545
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   546
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   547
     * Returns the value of the specified feature.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   548
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   549
     * @param cf the type of the Catalog feature
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   550
     * @return the value of the feature
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   551
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   552
    public String get(Feature cf) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   553
        return values[cf.ordinal()];
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   554
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   555
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   556
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   557
     * Initializes the supported properties
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   558
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   559
    private void init() {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   560
        values = new String[Feature.values().length];
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   561
        states = new State[Feature.values().length];
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   562
        for (Feature cf : Feature.values()) {
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
   563
            setProperty(cf, State.DEFAULT, cf.defaultValue());
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   564
        }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   565
        //read system properties or jaxp.properties
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   566
        readSystemProperties();
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   567
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   568
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   569
    /**
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   570
     * Sets properties by the Builder.
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   571
     * @param builder the CatalogFeatures builder
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   572
     */
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   573
    private void setProperties(Builder builder) {
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   574
        builder.values.entrySet().stream().forEach((entry) -> {
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
   575
            setProperty(entry.getKey(), State.APIPROPERTY, entry.getValue());
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   576
        });
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   577
    }
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   578
    /**
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
   579
     * Sets the value of a property, updates only if it shall override.
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   580
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   581
     * @param index the index of the property
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   582
     * @param state the state of the property
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   583
     * @param value the value of the property
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   584
     * @throws IllegalArgumentException if the value is invalid
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   585
     */
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
   586
    private void setProperty(Feature feature, State state, String value) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
   587
        int index = feature.ordinal();
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   588
        if (value != null && value.length() != 0) {
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
   589
            if (state != State.APIPROPERTY) {
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
   590
                Util.validateFeatureInput(feature, value);
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   591
            }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   592
            if (states[index] == null || state.compareTo(states[index]) >= 0) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   593
                values[index] = value;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   594
                states[index] = state;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   595
            }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   596
        }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   597
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   598
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   599
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   600
     * Reads from system properties, or those in jaxp.properties
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   601
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   602
    private void readSystemProperties() {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   603
        for (Feature cf : Feature.values()) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   604
            getSystemProperty(cf, cf.getPropertyName());
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   605
        }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   606
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   607
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   608
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   609
     * Reads from system properties, or those in jaxp.properties
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   610
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   611
     * @param cf the type of the property
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   612
     * @param sysPropertyName the name of system property
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   613
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   614
    private boolean getSystemProperty(Feature cf, String sysPropertyName) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   615
        if (cf.hasSystemProperty()) {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   616
            String value = SecuritySupport.getSystemProperty(sysPropertyName);
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   617
            if (value != null && !value.equals("")) {
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
   618
                setProperty(cf, State.SYSTEMPROPERTY, value);
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   619
                return true;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   620
            }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   621
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   622
            value = SecuritySupport.readJAXPProperty(sysPropertyName);
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   623
            if (value != null && !value.equals("")) {
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
   624
                setProperty(cf, State.JAXPDOTPROPERTIES, value);
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   625
                return true;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   626
            }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   627
        }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   628
        return false;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   629
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   630
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   631
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   632
     * Returns an instance of the builder for creating the CatalogFeatures object.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   633
     *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   634
     * @return an instance of the builder
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   635
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   636
    public static Builder builder() {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   637
        return new CatalogFeatures.Builder();
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   638
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   639
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   640
    /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   641
     * The Builder class for building the CatalogFeatures object.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   642
     */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   643
    public static class Builder {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   644
        /**
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   645
         * Values of the features supported by CatalogFeatures.
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   646
         */
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   647
        Map<Feature, String> values = new HashMap<>();
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   648
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   649
        /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   650
         * Instantiation of Builder is not allowed.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   651
         */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   652
        private Builder() {}
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   653
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   654
        /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   655
         * Sets the value to a specified Feature.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   656
         * @param feature the Feature to be set
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   657
         * @param value the value to be set for the Feature
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   658
         * @return this Builder instance
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   659
         * @throws IllegalArgumentException if the value is not valid for the
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   660
         * Feature or has the wrong syntax for the {@code javax.xml.catalog.files}
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   661
         * property
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   662
         */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   663
        public Builder with(Feature feature, String value) {
43121
e73af7b6ce47 8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents: 39907
diff changeset
   664
            Util.validateFeatureInput(feature, value);
36700
3afcaff239f5 8151154: IllegalArgumentException not thrown when wrong syntax value is set for javax.xml.catalog.files
joehw
parents: 33542
diff changeset
   665
            values.put(feature, value);
33542
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   666
            return this;
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   667
        }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   668
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   669
        /**
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   670
         * Returns a CatalogFeatures object built by this builder.
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   671
         *
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   672
         * @return an instance of CatalogFeatures
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   673
         */
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   674
        public CatalogFeatures build() {
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   675
            return new CatalogFeatures(this);
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   676
        }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   677
    }
9f0eef87e8c1 8081248: Implement JEP 268: XML Catalog API
joehw
parents:
diff changeset
   678
}