Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.naming/share/classes/javax/naming/Name.java
41152 views
1
/*
2
* Copyright (c) 1999, 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.naming;
27
28
import java.util.Enumeration;
29
30
/**
31
* The {@code Name} interface represents a generic name -- an ordered
32
* sequence of components. It can be a composite name (names that
33
* span multiple namespaces), or a compound name (names that are
34
* used within individual hierarchical naming systems).
35
*
36
* <p> There can be different implementations of {@code Name}; for example,
37
* composite names, URLs, or namespace-specific compound names.
38
*
39
* <p> The components of a name are numbered. The indexes of a name
40
* with N components range from 0 up to, but not including, N. This
41
* range may be written as [0,N).
42
* The most significant component is at index 0.
43
* An empty name has no components.
44
*
45
* <p> None of the methods in this interface accept null as a valid
46
* value for a parameter that is a name or a name component.
47
* Likewise, methods that return a name or name component never return null.
48
*
49
* <p> An instance of a {@code Name} may not be synchronized against
50
* concurrent multithreaded access if that access is not read-only.
51
*
52
* @author Rosanna Lee
53
* @author Scott Seligman
54
* @author R. Vasudevan
55
* @since 1.3
56
*/
57
58
public interface Name
59
extends Cloneable, java.io.Serializable, Comparable<Object>
60
{
61
62
/**
63
* The class fingerprint that is set to indicate
64
* serialization compatibility with a previous
65
* version of the class.
66
*
67
* @deprecated A {@code serialVersionUID} field in an interface is
68
* ineffectual. Do not use; no replacement.
69
*/
70
@Deprecated
71
@SuppressWarnings("serial")
72
static final long serialVersionUID = -3617482732056931635L;
73
74
/**
75
* Generates a new copy of this name.
76
* Subsequent changes to the components of this name will not
77
* affect the new copy, and vice versa.
78
*
79
* @return a copy of this name
80
*
81
* @see Object#clone()
82
*/
83
public Object clone();
84
85
/**
86
* Compares this name with another name for order.
87
* Returns a negative integer, zero, or a positive integer as this
88
* name is less than, equal to, or greater than the given name.
89
*
90
* <p> As with {@code Object.equals()}, the notion of ordering for names
91
* depends on the class that implements this interface.
92
* For example, the ordering may be
93
* based on lexicographical ordering of the name components.
94
* Specific attributes of the name, such as how it treats case,
95
* may affect the ordering. In general, two names of different
96
* classes may not be compared.
97
*
98
* @param obj the non-null object to compare against.
99
* @return a negative integer, zero, or a positive integer as this name
100
* is less than, equal to, or greater than the given name
101
* @throws ClassCastException if obj is not a {@code Name} of a
102
* type that may be compared with this name
103
*
104
* @see Comparable#compareTo(Object)
105
*/
106
public int compareTo(Object obj);
107
108
/**
109
* Returns the number of components in this name.
110
*
111
* @return the number of components in this name
112
*/
113
public int size();
114
115
/**
116
* Determines whether this name is empty.
117
* An empty name is one with zero components.
118
*
119
* @return true if this name is empty, false otherwise
120
*/
121
public boolean isEmpty();
122
123
/**
124
* Retrieves the components of this name as an enumeration
125
* of strings. The effect on the enumeration of updates to
126
* this name is undefined. If the name has zero components,
127
* an empty (non-null) enumeration is returned.
128
*
129
* @return an enumeration of the components of this name, each a string
130
*/
131
public Enumeration<String> getAll();
132
133
/**
134
* Retrieves a component of this name.
135
*
136
* @param posn
137
* the 0-based index of the component to retrieve.
138
* Must be in the range [0,size()).
139
* @return the component at index posn
140
* @throws ArrayIndexOutOfBoundsException
141
* if posn is outside the specified range
142
*/
143
public String get(int posn);
144
145
/**
146
* Creates a name whose components consist of a prefix of the
147
* components of this name. Subsequent changes to
148
* this name will not affect the name that is returned and vice versa.
149
*
150
* @param posn
151
* the 0-based index of the component at which to stop.
152
* Must be in the range [0,size()].
153
* @return a name consisting of the components at indexes in
154
* the range [0,posn).
155
* @throws ArrayIndexOutOfBoundsException
156
* if posn is outside the specified range
157
*/
158
public Name getPrefix(int posn);
159
160
/**
161
* Creates a name whose components consist of a suffix of the
162
* components in this name. Subsequent changes to
163
* this name do not affect the name that is returned and vice versa.
164
*
165
* @param posn
166
* the 0-based index of the component at which to start.
167
* Must be in the range [0,size()].
168
* @return a name consisting of the components at indexes in
169
* the range [posn,size()). If posn is equal to
170
* size(), an empty name is returned.
171
* @throws ArrayIndexOutOfBoundsException
172
* if posn is outside the specified range
173
*/
174
public Name getSuffix(int posn);
175
176
/**
177
* Determines whether this name starts with a specified prefix.
178
* A name {@code n} is a prefix if it is equal to
179
* {@code getPrefix(n.size())}.
180
*
181
* @param n
182
* the name to check
183
* @return true if {@code n} is a prefix of this name, false otherwise
184
*/
185
public boolean startsWith(Name n);
186
187
/**
188
* Determines whether this name ends with a specified suffix.
189
* A name {@code n} is a suffix if it is equal to
190
* {@code getSuffix(size()-n.size())}.
191
*
192
* @param n
193
* the name to check
194
* @return true if {@code n} is a suffix of this name, false otherwise
195
*/
196
public boolean endsWith(Name n);
197
198
/**
199
* Adds the components of a name -- in order -- to the end of this name.
200
*
201
* @param suffix
202
* the components to add
203
* @return the updated name (not a new one)
204
*
205
* @throws InvalidNameException if {@code suffix} is not a valid name,
206
* or if the addition of the components would violate the syntax
207
* rules of this name
208
*/
209
public Name addAll(Name suffix) throws InvalidNameException;
210
211
/**
212
* Adds the components of a name -- in order -- at a specified position
213
* within this name.
214
* Components of this name at or after the index of the first new
215
* component are shifted up (away from 0) to accommodate the new
216
* components.
217
*
218
* @param n
219
* the components to add
220
* @param posn
221
* the index in this name at which to add the new
222
* components. Must be in the range [0,size()].
223
* @return the updated name (not a new one)
224
*
225
* @throws ArrayIndexOutOfBoundsException
226
* if posn is outside the specified range
227
* @throws InvalidNameException if {@code n} is not a valid name,
228
* or if the addition of the components would violate the syntax
229
* rules of this name
230
*/
231
public Name addAll(int posn, Name n) throws InvalidNameException;
232
233
/**
234
* Adds a single component to the end of this name.
235
*
236
* @param comp
237
* the component to add
238
* @return the updated name (not a new one)
239
*
240
* @throws InvalidNameException if adding {@code comp} would violate
241
* the syntax rules of this name
242
*/
243
public Name add(String comp) throws InvalidNameException;
244
245
/**
246
* Adds a single component at a specified position within this name.
247
* Components of this name at or after the index of the new component
248
* are shifted up by one (away from index 0) to accommodate the new
249
* component.
250
*
251
* @param comp
252
* the component to add
253
* @param posn
254
* the index at which to add the new component.
255
* Must be in the range [0,size()].
256
* @return the updated name (not a new one)
257
*
258
* @throws ArrayIndexOutOfBoundsException
259
* if posn is outside the specified range
260
* @throws InvalidNameException if adding {@code comp} would violate
261
* the syntax rules of this name
262
*/
263
public Name add(int posn, String comp) throws InvalidNameException;
264
265
/**
266
* Removes a component from this name.
267
* The component of this name at the specified position is removed.
268
* Components with indexes greater than this position
269
* are shifted down (toward index 0) by one.
270
*
271
* @param posn
272
* the index of the component to remove.
273
* Must be in the range [0,size()).
274
* @return the component removed (a String)
275
*
276
* @throws ArrayIndexOutOfBoundsException
277
* if posn is outside the specified range
278
* @throws InvalidNameException if deleting the component
279
* would violate the syntax rules of the name
280
*/
281
public Object remove(int posn) throws InvalidNameException;
282
}
283
284