author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 43121 | jaxp/src/java.xml/share/classes/javax/xml/catalog/UriEntry.java@e73af7b6ce47 |
permissions | -rw-r--r-- |
33542 | 1 |
/* |
43121
e73af7b6ce47
8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents:
38497
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 |
package javax.xml.catalog; |
|
26 |
||
27 |
import java.net.URL; |
|
28 |
||
29 |
/** |
|
43121
e73af7b6ce47
8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents:
38497
diff
changeset
|
30 |
* Represents a uri entry. |
33542 | 31 |
* |
32 |
* @since 9 |
|
33 |
*/ |
|
34 |
final class UriEntry extends BaseEntry { |
|
35 |
String name; |
|
36 |
URL uri; |
|
37 |
||
38 |
/** |
|
43121
e73af7b6ce47
8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
joehw
parents:
38497
diff
changeset
|
39 |
* Construct a uri entry. |
33542 | 40 |
* @param name The name attribute. |
41 |
* @param uri The uri attribute. |
|
42 |
*/ |
|
43 |
public UriEntry(String base, String name, String uri) { |
|
44 |
super(CatalogEntryType.URI, base); |
|
45 |
setName(name); |
|
46 |
setURI(uri); |
|
47 |
} |
|
48 |
||
49 |
/** |
|
50 |
* Set the name attribute. |
|
51 |
* @param name The name attribute value. |
|
52 |
*/ |
|
53 |
public void setName(String name) { |
|
54 |
CatalogMessages.reportNPEOnNull("name", name); |
|
38497 | 55 |
if (name.startsWith(Util.PUBLICID_PREFIX) || name.startsWith(Util.PUBLICID_PREFIX_ALT)) { |
56 |
this.name = Normalizer.normalizePublicId(name); |
|
57 |
} else { |
|
58 |
this.name = Normalizer.normalizeURI(name); |
|
59 |
} |
|
33542 | 60 |
} |
61 |
||
62 |
/** |
|
63 |
* Set the uri attribute. If the value of the uri attribute is relative, it |
|
64 |
* must be made absolute with respect to the base URI currently in effect. |
|
65 |
* |
|
66 |
* @param uri The uri attribute value. |
|
67 |
*/ |
|
68 |
public void setURI(String uri) { |
|
69 |
this.uri = verifyURI("setURI", baseURI, uri); |
|
70 |
} |
|
71 |
||
72 |
/** |
|
73 |
* Get the name attribute. |
|
74 |
* @return The name |
|
75 |
*/ |
|
76 |
public String getName() { |
|
77 |
return name; |
|
78 |
} |
|
38497 | 79 |
|
33542 | 80 |
/** |
81 |
* Get the uri attribute. |
|
82 |
* @return The uri attribute value. |
|
83 |
*/ |
|
84 |
public URL getURI() { |
|
85 |
return uri; |
|
86 |
} |
|
87 |
||
88 |
@Override |
|
89 |
public String match(String name) { |
|
90 |
if (this.name.equals(name)) { |
|
91 |
return uri.toString(); |
|
92 |
} |
|
93 |
return null; |
|
94 |
} |
|
95 |
} |