Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.xml/share/classes/javax/xml/namespace/NamespaceContext.java
40948 views
1
/*
2
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
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.namespace;
27
28
import java.util.Iterator;
29
30
/**
31
* Interface for read only XML Namespace context processing.
32
*
33
* <p>An XML Namespace has the properties:
34
* <ul>
35
* <li>Namespace URI:
36
* Namespace name expressed as a URI to which the prefix is bound</li>
37
* <li>prefix: syntactically, this is the part of the attribute name
38
* following the {@code XMLConstants.XMLNS_ATTRIBUTE}
39
* ("xmlns") in the Namespace declaration</li>
40
* </ul>
41
* <p>example:
42
* {@code <element xmlns:prefix="http://Namespace-name-URI">}
43
*
44
* <p>All {@code get*(*)} methods operate in the current scope
45
* for Namespace URI and prefix resolution.
46
*
47
* <p>Note that a Namespace URI can be bound to
48
* <strong>multiple</strong> prefixes in the current scope. This can
49
* occur when multiple {@code XMLConstants.XMLNS_ATTRIBUTE}
50
* ("xmlns") Namespace declarations occur in the same Start-Tag and
51
* refer to the same Namespace URI. e.g.<br>
52
* <pre> {@code
53
* <element xmlns:prefix1="http://Namespace-name-URI"
54
* xmlns:prefix2="http://Namespace-name-URI"> }
55
* </pre>
56
* This can also occur when the same Namespace URI is used in multiple
57
* {@code XMLConstants.XMLNS_ATTRIBUTE} ("xmlns") Namespace
58
* declarations in the logical parent element hierarchy. e.g.<br>
59
* <pre> {@code
60
* <parent xmlns:prefix1="http://Namespace-name-URI">
61
* <child xmlns:prefix2="http://Namespace-name-URI">
62
* ...
63
* </child>
64
* </parent> }
65
* </pre>
66
*
67
* <p>A prefix can only be bound to a <strong>single</strong>
68
* Namespace URI in the current scope.
69
*
70
* @author Jeff Suttor
71
* @see javax.xml.XMLConstants
72
* javax.xml.XMLConstants for declarations of common XML values
73
* @see <a href="http://www.w3.org/TR/xmlschema-2/#QName">
74
* XML Schema Part2: Datatypes</a>
75
* @see <a href="http://www.w3.org/TR/REC-xml-names/">
76
* Namespaces in XML</a>
77
* @since 1.5
78
*/
79
80
public interface NamespaceContext {
81
82
/**
83
* Get Namespace URI bound to a prefix in the current scope.
84
*
85
* <p>When requesting a Namespace URI by prefix, the following
86
* table describes the returned Namespace URI value for all
87
* possible prefix values:
88
*
89
* <table class="striped">
90
* <caption>Return value for specified prefixes</caption>
91
* <thead>
92
* <tr>
93
* <th scope="col">prefix parameter</th>
94
* <th scope="col">Namespace URI return value</th>
95
* </tr>
96
* </thead>
97
* <tbody>
98
* <tr>
99
* <th scope="row">{@code DEFAULT_NS_PREFIX} ("")</th>
100
* <td>default Namespace URI in the current scope or
101
* <code> {@link
102
* javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI("")}
103
* </code>
104
* when there is no default Namespace URI in the current scope</td>
105
* </tr>
106
* <tr>
107
* <th scope="row">bound prefix</th>
108
* <td>Namespace URI bound to prefix in current scope</td>
109
* </tr>
110
* <tr>
111
* <th scope="row">unbound prefix</th>
112
* <td>
113
* <code> {@link
114
* javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI("")}
115
* </code>
116
* </td>
117
* </tr>
118
* <tr>
119
* <th scope="row">{@code XMLConstants.XML_NS_PREFIX} ("xml")</th>
120
* <td>{@code XMLConstants.XML_NS_URI}
121
* ("http://www.w3.org/XML/1998/namespace")</td>
122
* </tr>
123
* <tr>
124
* <th scope="row">{@code XMLConstants.XMLNS_ATTRIBUTE} ("xmlns")</th>
125
* <td>{@code XMLConstants.XMLNS_ATTRIBUTE_NS_URI}
126
* ("http://www.w3.org/2000/xmlns/")</td>
127
* </tr>
128
* <tr>
129
* <th scope="row">{@code null}</th>
130
* <td>{@code IllegalArgumentException} is thrown</td>
131
* </tr>
132
* </tbody>
133
* </table>
134
*
135
* @param prefix prefix to look up
136
*
137
* @return Namespace URI bound to prefix in the current scope
138
*
139
* @throws IllegalArgumentException When {@code prefix} is
140
* {@code null}
141
*/
142
String getNamespaceURI(String prefix);
143
144
/**
145
* Get prefix bound to Namespace URI in the current scope.
146
*
147
* <p>To get all prefixes bound to a Namespace URI in the current
148
* scope, use {@link #getPrefixes(String namespaceURI)}.
149
*
150
* <p>When requesting a prefix by Namespace URI, the following
151
* table describes the returned prefix value for all Namespace URI
152
* values:
153
*
154
* <table class="striped">
155
* <caption>Return value for specified Namespace URIs</caption>
156
* <thead>
157
* <tr>
158
* <th scope="col">Namespace URI parameter</th>
159
* <th scope="col">prefix value returned</th>
160
* </tr>
161
* </thead>
162
* <tbody>
163
* <tr>
164
* <th scope="row">{@code <default Namespace URI>}</th>
165
* <td>{@code XMLConstants.DEFAULT_NS_PREFIX} ("")
166
* </td>
167
* </tr>
168
* <tr>
169
* <th scope="row">bound Namespace URI</th>
170
* <td>prefix bound to Namespace URI in the current scope,
171
* if multiple prefixes are bound to the Namespace URI in
172
* the current scope, a single arbitrary prefix, whose
173
* choice is implementation dependent, is returned</td>
174
* </tr>
175
* <tr>
176
* <th scope="row">unbound Namespace URI</th>
177
* <td>{@code null}</td>
178
* </tr>
179
* <tr>
180
* <th scope="row">{@code XMLConstants.XML_NS_URI}
181
* ("http://www.w3.org/XML/1998/namespace")</th>
182
* <td>{@code XMLConstants.XML_NS_PREFIX} ("xml")</td>
183
* </tr>
184
* <tr>
185
* <th scope="row">{@code XMLConstants.XMLNS_ATTRIBUTE_NS_URI}
186
* ("http://www.w3.org/2000/xmlns/")</th>
187
* <td>{@code XMLConstants.XMLNS_ATTRIBUTE} ("xmlns")</td>
188
* </tr>
189
* <tr>
190
* <th scope="row">{@code null}</th>
191
* <td>{@code IllegalArgumentException} is thrown</td>
192
* </tr>
193
* </tbody>
194
* </table>
195
*
196
* @param namespaceURI URI of Namespace to lookup
197
*
198
* @return prefix bound to Namespace URI in current context
199
*
200
* @throws IllegalArgumentException When {@code namespaceURI} is
201
* {@code null}
202
*/
203
String getPrefix(String namespaceURI);
204
205
/**
206
* Get all prefixes bound to a Namespace URI in the current
207
* scope.
208
*
209
* <p>An Iterator over String elements is returned in an arbitrary,
210
* <strong>implementation dependent</strong>, order.
211
*
212
* <p><strong>The {@code Iterator} is
213
* <em>not</em> modifiable. e.g. the
214
* {@code remove()} method will throw
215
* {@code UnsupportedOperationException}.</strong>
216
*
217
* <p>When requesting prefixes by Namespace URI, the following
218
* table describes the returned prefixes value for all Namespace
219
* URI values:
220
*
221
* <table class="striped">
222
* <caption>Return value for specified Namespace URIs</caption>
223
* <thead>
224
* <tr>
225
* <th scope="col">Namespace URI parameter</th>
226
* <th scope="col">prefixes value returned</th>
227
* </tr>
228
* </thead>
229
* <tbody>
230
* <tr>
231
* <th scope="row">bound Namespace URI,
232
* including the {@code <default Namespace URI>}</th>
233
* <td>
234
* {@code Iterator} over prefixes bound to Namespace URI in
235
* the current scope in an arbitrary,
236
* <strong>implementation dependent</strong>,
237
* order
238
* </td>
239
* </tr>
240
* <tr>
241
* <th scope="row">unbound Namespace URI</th>
242
* <td>empty {@code Iterator}</td>
243
* </tr>
244
* <tr>
245
* <th scope="row">{@code XMLConstants.XML_NS_URI}
246
* ("http://www.w3.org/XML/1998/namespace")</th>
247
* <td>{@code Iterator} with one element set to
248
* {@code XMLConstants.XML_NS_PREFIX} ("xml")</td>
249
* </tr>
250
* <tr>
251
* <th scope="row">{@code XMLConstants.XMLNS_ATTRIBUTE_NS_URI}
252
* ("http://www.w3.org/2000/xmlns/")</th>
253
* <td>{@code Iterator} with one element set to
254
* {@code XMLConstants.XMLNS_ATTRIBUTE} ("xmlns")</td>
255
* </tr>
256
* <tr>
257
* <th scope="row">{@code null}</th>
258
* <td>{@code IllegalArgumentException} is thrown</td>
259
* </tr>
260
* </tbody>
261
* </table>
262
*
263
* @param namespaceURI URI of Namespace to lookup
264
*
265
* @return {@code Iterator} for all prefixes bound to the
266
* Namespace URI in the current scope
267
*
268
* @throws IllegalArgumentException When {@code namespaceURI} is
269
* {@code null}
270
*/
271
Iterator<String> getPrefixes(String namespaceURI);
272
}
273
274