author | joehw |
Wed, 11 Jan 2017 13:06:04 -0800 | |
changeset 43121 | e73af7b6ce47 |
parent 40582 | 1dddef49982c |
child 45855 | 46c3f654e80f |
permissions | -rw-r--r-- |
33542 | 1 |
/* |
43121
e73af7b6ce47
8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents:
40582
diff
changeset
|
2 |
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
33542 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package javax.xml.catalog; |
|
27 |
||
28 |
import java.util.stream.Stream; |
|
29 |
||
30 |
/** |
|
31 |
* The Catalog class represents an entity Catalog as defined by |
|
32 |
* <a |
|
33 |
* href="https://www.oasis-open.org/committees/download.php/14809/xml-catalogs.html"> |
|
34 |
* XML Catalogs, OASIS Standard V1.1, 7 October 2005</a>. |
|
35 |
* <p> |
|
36 |
* A catalog is an XML file that contains a root {@code catalog} entry with a list |
|
37 |
* of catalog entries. The entries can also be grouped with a {@code group} entry. |
|
38 |
* The catalog and group entries may specify {@code prefer} and {@code xml:base} |
|
39 |
* attributes that set preference of public or system type of entries and base URI |
|
40 |
* to resolve relative URIs. |
|
41 |
* |
|
42 |
* <p> |
|
43 |
* A catalog can be used in two situations: |
|
44 |
* <ul> |
|
40582
1dddef49982c
8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers
joehw
parents:
33542
diff
changeset
|
45 |
* <li>Locate the external resources with a public or system identifier; |
33542 | 46 |
* </li> |
43121
e73af7b6ce47
8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents:
40582
diff
changeset
|
47 |
* <li>Locate an alternate URI reference with a URI. |
33542 | 48 |
* </li> |
49 |
* </ul> |
|
50 |
* <p> |
|
51 |
* For case 1, the standard defines 6 External Identifier Entries:<br> |
|
52 |
* {@code public, system, rewriteSystem, systemSuffix, delegatePublic, and |
|
53 |
* delegateSystem}. |
|
54 |
* <p> |
|
55 |
* While for case 2, it defines 4 URI Entries:<br> |
|
56 |
* {@code uri, rewriteURI, uriSuffix and delegateURI}. |
|
57 |
* <p> |
|
58 |
* In addition to the above entry types, a catalog may define nextCatalog |
|
59 |
* entries to add additional catalog entry files. |
|
60 |
* <p> |
|
61 |
* |
|
62 |
* @since 9 |
|
63 |
*/ |
|
64 |
public interface Catalog { |
|
65 |
||
66 |
/** |
|
67 |
* Attempts to find a matching entry in the catalog by systemId. |
|
68 |
* |
|
69 |
* <p> |
|
70 |
* The method searches through the system-type entries, including {@code system, |
|
71 |
* rewriteSystem, systemSuffix, delegateSystem}, and {@code group} entries in the |
|
72 |
* current catalog in order to find a match. |
|
73 |
* <p> |
|
74 |
* Resolution follows the steps listed below: <br> |
|
75 |
* <ul> |
|
76 |
* <li>If a matching {@code system} entry exists, it is returned immediately.</li> |
|
77 |
* <li>If more than one {@code rewriteSystem} entry matches, the matching entry with |
|
78 |
* the longest normalized {@code systemIdStartString} value is returned.</li> |
|
79 |
* <li>If more than one {@code systemSuffix} entry matches, the matching entry |
|
80 |
* with the longest normalized {@code systemIdSuffix} value is returned.</li> |
|
81 |
* <li>If more than one {@code delegateSystem} entry matches, the matching entry |
|
82 |
* with the longest matching {@code systemIdStartString} value is returned.</li> |
|
83 |
* </ul> |
|
84 |
* |
|
85 |
* @param systemId the system identifier of the entity to be matched |
|
86 |
* |
|
43121
e73af7b6ce47
8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents:
40582
diff
changeset
|
87 |
* @return a URI string if a mapping is found, or null otherwise |
33542 | 88 |
*/ |
89 |
public String matchSystem(String systemId); |
|
90 |
||
91 |
/** |
|
92 |
* Attempts to find a matching entry in the catalog by publicId. The method |
|
93 |
* searches through the public-type entries, including {@code public, |
|
94 |
* delegatePublic}, and {@code group} entries in the current catalog in order to find |
|
95 |
* a match. |
|
96 |
* <p> |
|
97 |
* Refer to the description about <a href="CatalogFeatures.html#PREFER"> |
|
98 |
* Feature PREFER in the table Catalog Features</a> in class |
|
99 |
* {@link CatalogFeatures}. Public entries are only considered if the |
|
100 |
* {@code prefer} is {@code public} and {@code system} entries are not found. |
|
101 |
* <p> |
|
102 |
* Resolution follows the steps listed below: <br> |
|
103 |
* <ul> |
|
104 |
* <li>If a matching {@code public} entry is found, it is returned immediately.</li> |
|
105 |
* <li>If more than one {@code delegatePublic} entry matches, the matching entry |
|
106 |
* with the longest matching {@code publicIdStartString} value is returned.</li> |
|
107 |
* </ul> |
|
108 |
* |
|
109 |
* @param publicId the public identifier of the entity to be matched |
|
110 |
* @see CatalogFeatures.Feature |
|
43121
e73af7b6ce47
8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents:
40582
diff
changeset
|
111 |
* @return a URI string if a mapping is found, or null otherwise |
33542 | 112 |
*/ |
113 |
public String matchPublic(String publicId); |
|
114 |
||
115 |
/** |
|
116 |
* Attempts to find a matching entry in the catalog by the uri element. |
|
117 |
* |
|
118 |
* <p> |
|
119 |
* The method searches through the uri-type entries, including {@code uri, |
|
120 |
* rewriteURI, uriSuffix, delegateURI} and {@code group} entries in the current |
|
121 |
* catalog in order to find a match. |
|
122 |
* |
|
123 |
* <p> |
|
124 |
* Resolution follows the steps listed below: <br> |
|
125 |
* <ul> |
|
126 |
* <li>If a matching {@code uri} entry is found, it is returned immediately.</li> |
|
127 |
* <li>If more than one {@code rewriteURI} entry matches, the matching entry with |
|
128 |
* the longest normalized {@code uriStartString} value is returned.</li> |
|
129 |
* <li>If more than one {@code uriSuffix} entry matches, the matching entry with |
|
130 |
* the longest normalized {@code uriSuffix} value is returned.</li> |
|
131 |
* <li>If more than one {@code delegatePublic} entry matches, the matching entry |
|
132 |
* with the longest matching {@code uriStartString} value is returned.</li> |
|
133 |
* </ul> |
|
134 |
* |
|
135 |
* @param uri the URI reference of the entity to be matched |
|
136 |
* |
|
43121
e73af7b6ce47
8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents:
40582
diff
changeset
|
137 |
* @return a URI string if a mapping is found, or null otherwise |
33542 | 138 |
*/ |
139 |
public String matchURI(String uri); |
|
140 |
||
141 |
/** |
|
142 |
* Returns a sequential Stream of alternative Catalogs specified using the |
|
143 |
* {@code nextCatalog} entries in the current catalog, and as the input of |
|
144 |
* catalog files excluding the current catalog (that is, the first in the |
|
145 |
* input list) when the Catalog object is created by the {@link CatalogManager}. |
|
146 |
* <p> |
|
147 |
* The order of Catalogs in the returned stream is the same as the order |
|
148 |
* in which the corresponding {@code nextCatalog} entries appear in the |
|
149 |
* current catalog. The alternative catalogs from the input file list are |
|
150 |
* appended to the end of the stream in the order they are entered. |
|
151 |
* |
|
152 |
* @return a sequential Stream of Catalogs |
|
153 |
*/ |
|
154 |
public Stream<Catalog> catalogs(); |
|
155 |
||
156 |
} |