author | darcy |
Wed, 27 Nov 2019 06:36:41 -0800 | |
changeset 59295 | 8b6cc0bb93d0 |
parent 51437 | 6221a199ec20 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
51317
e122220d7d7e
8209024: Use SuppressWarnings on serialVersionUID fields in interfaces
darcy
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
||
26 |
package javax.naming.directory; |
|
27 |
||
28 |
import java.util.Vector; |
|
29 |
import java.util.Enumeration; |
|
30 |
import java.util.NoSuchElementException; |
|
31 |
||
32 |
import javax.naming.NamingException; |
|
33 |
import javax.naming.NamingEnumeration; |
|
34 |
import javax.naming.OperationNotSupportedException; |
|
35 |
||
36 |
/** |
|
37 |
* This interface represents an attribute associated with a named object. |
|
38 |
*<p> |
|
39 |
* In a directory, named objects can have associated with them |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
40 |
* attributes. The {@code Attribute} interface represents an attribute associated |
2 | 41 |
* with a named object. An attribute contains 0 or more, possibly null, values. |
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
42 |
* The attribute values can be ordered or unordered (see {@code isOrdered()}). |
2 | 43 |
* If the values are unordered, no duplicates are allowed. |
44 |
* If the values are ordered, duplicates are allowed. |
|
45 |
*<p> |
|
46 |
* The content and representation of an attribute and its values is defined by |
|
47 |
* the attribute's <em>schema</em>. The schema contains information |
|
48 |
* about the attribute's syntax and other properties about the attribute. |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
49 |
* See {@code getAttributeDefinition()} and |
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
50 |
* {@code getAttributeSyntaxDefinition()} |
2 | 51 |
* for details regarding how to get schema information about an attribute |
52 |
* if the underlying directory service supports schemas. |
|
53 |
*<p> |
|
54 |
* Equality of two attributes is determined by the implementation class. |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
55 |
* A simple implementation can use {@code Object.equals()} to determine equality |
2 | 56 |
* of attribute values, while a more sophisticated implementation might |
57 |
* make use of schema information to determine equality. |
|
58 |
* Similarly, one implementation might provide a static storage |
|
59 |
* structure which simply returns the values passed to its |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
60 |
* constructor, while another implementation might define {@code get()} and |
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
61 |
* {@code getAll()}. |
2 | 62 |
* to get the values dynamically from the directory. |
63 |
*<p> |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
64 |
* Note that updates to {@code Attribute} (such as adding or removing a |
2 | 65 |
* value) do not affect the corresponding representation of the attribute |
66 |
* in the directory. Updates to the directory can only be effected |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
67 |
* using operations in the {@code DirContext} interface. |
2 | 68 |
* |
69 |
* @author Rosanna Lee |
|
70 |
* @author Scott Seligman |
|
71 |
* |
|
72 |
* @see BasicAttribute |
|
73 |
* @since 1.3 |
|
74 |
*/ |
|
75 |
public interface Attribute extends Cloneable, java.io.Serializable { |
|
76 |
/** |
|
77 |
* Retrieves an enumeration of the attribute's values. |
|
78 |
* The behaviour of this enumeration is unspecified |
|
79 |
* if the attribute's values are added, changed, |
|
80 |
* or removed while the enumeration is in progress. |
|
81 |
* If the attribute values are ordered, the enumeration's items |
|
82 |
* will be ordered. |
|
83 |
* |
|
84 |
* @return A non-null enumeration of the attribute's values. |
|
85 |
* Each element of the enumeration is a possibly null Object. The object's |
|
86 |
* class is the class of the attribute value. The element is null |
|
87 |
* if the attribute's value is null. |
|
88 |
* If the attribute has zero values, an empty enumeration |
|
89 |
* is returned. |
|
90 |
* @exception NamingException |
|
91 |
* If a naming exception was encountered while retrieving |
|
92 |
* the values. |
|
93 |
* @see #isOrdered |
|
94 |
*/ |
|
95 |
NamingEnumeration<?> getAll() throws NamingException; |
|
96 |
||
97 |
/** |
|
98 |
* Retrieves one of this attribute's values. |
|
99 |
* If the attribute has more than one value and is unordered, any one of |
|
100 |
* the values is returned. |
|
101 |
* If the attribute has more than one value and is ordered, the |
|
102 |
* first value is returned. |
|
103 |
* |
|
104 |
* @return A possibly null object representing one of |
|
105 |
* the attribute's value. It is null if the attribute's value |
|
106 |
* is null. |
|
107 |
* @exception NamingException |
|
108 |
* If a naming exception was encountered while retrieving |
|
109 |
* the value. |
|
110 |
* @exception java.util.NoSuchElementException |
|
111 |
* If this attribute has no values. |
|
112 |
*/ |
|
113 |
Object get() throws NamingException; |
|
114 |
||
115 |
/** |
|
116 |
* Retrieves the number of values in this attribute. |
|
117 |
* |
|
118 |
* @return The nonnegative number of values in this attribute. |
|
119 |
*/ |
|
120 |
int size(); |
|
121 |
||
122 |
/** |
|
123 |
* Retrieves the id of this attribute. |
|
124 |
* |
|
125 |
* @return The id of this attribute. It cannot be null. |
|
126 |
*/ |
|
127 |
String getID(); |
|
128 |
||
129 |
/** |
|
130 |
* Determines whether a value is in the attribute. |
|
131 |
* Equality is determined by the implementation, which may use |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
132 |
* {@code Object.equals()} or schema information to determine equality. |
2 | 133 |
* |
134 |
* @param attrVal The possibly null value to check. If null, check |
|
135 |
* whether the attribute has an attribute value whose value is null. |
|
136 |
* @return true if attrVal is one of this attribute's values; false otherwise. |
|
137 |
* @see java.lang.Object#equals |
|
138 |
* @see BasicAttribute#equals |
|
139 |
*/ |
|
140 |
boolean contains(Object attrVal); |
|
141 |
/** |
|
142 |
* Adds a new value to the attribute. |
|
143 |
* If the attribute values are unordered and |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
144 |
* {@code attrVal} is already in the attribute, this method does nothing. |
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
145 |
* If the attribute values are ordered, {@code attrVal} is added to the end of |
2 | 146 |
* the list of attribute values. |
147 |
*<p> |
|
148 |
* Equality is determined by the implementation, which may use |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
149 |
* {@code Object.equals()} or schema information to determine equality. |
2 | 150 |
* |
151 |
* @param attrVal The new possibly null value to add. If null, null |
|
152 |
* is added as an attribute value. |
|
153 |
* @return true if a value was added; false otherwise. |
|
154 |
*/ |
|
155 |
boolean add(Object attrVal); |
|
156 |
||
157 |
/** |
|
158 |
* Removes a specified value from the attribute. |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
159 |
* If {@code attrval} is not in the attribute, this method does nothing. |
2 | 160 |
* If the attribute values are ordered, the first occurrence of |
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
161 |
* {@code attrVal} is removed and attribute values at indices greater |
2 | 162 |
* than the removed |
163 |
* value are shifted up towards the head of the list (and their indices |
|
164 |
* decremented by one). |
|
165 |
*<p> |
|
166 |
* Equality is determined by the implementation, which may use |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
167 |
* {@code Object.equals()} or schema information to determine equality. |
2 | 168 |
* |
169 |
* @param attrval The possibly null value to remove from this attribute. |
|
170 |
* If null, remove the attribute value that is null. |
|
171 |
* @return true if the value was removed; false otherwise. |
|
172 |
*/ |
|
173 |
boolean remove(Object attrval); |
|
174 |
||
175 |
/** |
|
176 |
* Removes all values from this attribute. |
|
177 |
*/ |
|
178 |
void clear(); |
|
179 |
||
180 |
/** |
|
181 |
* Retrieves the syntax definition associated with the attribute. |
|
182 |
* An attribute's syntax definition specifies the format |
|
183 |
* of the attribute's value(s). Note that this is different from |
|
184 |
* the attribute value's representation as a Java object. Syntax |
|
185 |
* definition refers to the directory's notion of <em>syntax</em>. |
|
186 |
*<p> |
|
187 |
* For example, even though a value might be |
|
188 |
* a Java String object, its directory syntax might be "Printable String" |
|
189 |
* or "Telephone Number". Or a value might be a byte array, and its |
|
190 |
* directory syntax is "JPEG" or "Certificate". |
|
191 |
* For example, if this attribute's syntax is "JPEG", |
|
192 |
* this method would return the syntax definition for "JPEG". |
|
193 |
* <p> |
|
194 |
* The information that you can retrieve from a syntax definition |
|
195 |
* is directory-dependent. |
|
196 |
*<p> |
|
197 |
* If an implementation does not support schemas, it should throw |
|
198 |
* OperationNotSupportedException. If an implementation does support |
|
199 |
* schemas, it should define this method to return the appropriate |
|
200 |
* information. |
|
201 |
* @return The attribute's syntax definition. Null if the implementation |
|
202 |
* supports schemas but this particular attribute does not have |
|
203 |
* any schema information. |
|
204 |
* @exception OperationNotSupportedException If getting the schema |
|
205 |
* is not supported. |
|
206 |
* @exception NamingException If a naming exception occurs while getting |
|
207 |
* the schema. |
|
208 |
*/ |
|
209 |
||
210 |
DirContext getAttributeSyntaxDefinition() throws NamingException; |
|
211 |
||
212 |
/** |
|
213 |
* Retrieves the attribute's schema definition. |
|
214 |
* An attribute's schema definition contains information |
|
215 |
* such as whether the attribute is multivalued or single-valued, |
|
216 |
* the matching rules to use when comparing the attribute's values. |
|
217 |
* |
|
218 |
* The information that you can retrieve from an attribute definition |
|
219 |
* is directory-dependent. |
|
220 |
* |
|
221 |
*<p> |
|
222 |
* If an implementation does not support schemas, it should throw |
|
223 |
* OperationNotSupportedException. If an implementation does support |
|
224 |
* schemas, it should define this method to return the appropriate |
|
225 |
* information. |
|
226 |
* @return This attribute's schema definition. Null if the implementation |
|
227 |
* supports schemas but this particular attribute does not have |
|
228 |
* any schema information. |
|
229 |
* @exception OperationNotSupportedException If getting the schema |
|
230 |
* is not supported. |
|
231 |
* @exception NamingException If a naming exception occurs while getting |
|
232 |
* the schema. |
|
233 |
*/ |
|
234 |
DirContext getAttributeDefinition() throws NamingException; |
|
235 |
||
236 |
/** |
|
237 |
* Makes a copy of the attribute. |
|
238 |
* The copy contains the same attribute values as the original attribute: |
|
239 |
* the attribute values are not themselves cloned. |
|
240 |
* Changes to the copy will not affect the original and vice versa. |
|
241 |
* |
|
242 |
* @return A non-null copy of the attribute. |
|
243 |
*/ |
|
244 |
Object clone(); |
|
245 |
||
246 |
//----------- Methods to support ordered multivalued attributes |
|
247 |
||
248 |
/** |
|
249 |
* Determines whether this attribute's values are ordered. |
|
250 |
* If an attribute's values are ordered, duplicate values are allowed. |
|
251 |
* If an attribute's values are unordered, they are presented |
|
252 |
* in any order and there are no duplicate values. |
|
253 |
* @return true if this attribute's values are ordered; false otherwise. |
|
254 |
* @see #get(int) |
|
255 |
* @see #remove(int) |
|
256 |
* @see #add(int, java.lang.Object) |
|
257 |
* @see #set(int, java.lang.Object) |
|
258 |
*/ |
|
259 |
boolean isOrdered(); |
|
260 |
||
261 |
/** |
|
262 |
* Retrieves the attribute value from the ordered list of attribute values. |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
263 |
* This method returns the value at the {@code ix} index of the list of |
2 | 264 |
* attribute values. |
265 |
* If the attribute values are unordered, |
|
266 |
* this method returns the value that happens to be at that index. |
|
267 |
* @param ix The index of the value in the ordered list of attribute values. |
|
18156 | 268 |
* {@code 0 <= ix < size()}. |
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
269 |
* @return The possibly null attribute value at index {@code ix}; |
2 | 270 |
* null if the attribute value is null. |
271 |
* @exception NamingException If a naming exception was encountered while |
|
272 |
* retrieving the value. |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
273 |
* @exception IndexOutOfBoundsException If {@code ix} is outside the specified range. |
2 | 274 |
*/ |
275 |
Object get(int ix) throws NamingException; |
|
276 |
||
277 |
/** |
|
278 |
* Removes an attribute value from the ordered list of attribute values. |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
279 |
* This method removes the value at the {@code ix} index of the list of |
2 | 280 |
* attribute values. |
281 |
* If the attribute values are unordered, |
|
282 |
* this method removes the value that happens to be at that index. |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
283 |
* Values located at indices greater than {@code ix} are shifted up towards |
2 | 284 |
* the front of the list (and their indices decremented by one). |
285 |
* |
|
286 |
* @param ix The index of the value to remove. |
|
18156 | 287 |
* {@code 0 <= ix < size()}. |
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
288 |
* @return The possibly null attribute value at index {@code ix} that was removed; |
2 | 289 |
* null if the attribute value is null. |
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
290 |
* @exception IndexOutOfBoundsException If {@code ix} is outside the specified range. |
2 | 291 |
*/ |
292 |
Object remove(int ix); |
|
293 |
||
294 |
/** |
|
295 |
* Adds an attribute value to the ordered list of attribute values. |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
296 |
* This method adds {@code attrVal} to the list of attribute values at |
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
297 |
* index {@code ix}. |
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
298 |
* Values located at indices at or greater than {@code ix} are |
2 | 299 |
* shifted down towards the end of the list (and their indices incremented |
300 |
* by one). |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
301 |
* If the attribute values are unordered and already have {@code attrVal}, |
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
302 |
* {@code IllegalStateException} is thrown. |
2 | 303 |
* |
304 |
* @param ix The index in the ordered list of attribute values to add the new value. |
|
18156 | 305 |
* {@code 0 <= ix <= size()}. |
2 | 306 |
* @param attrVal The possibly null attribute value to add; if null, null is |
307 |
* the value added. |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
308 |
* @exception IndexOutOfBoundsException If {@code ix} is outside the specified range. |
2 | 309 |
* @exception IllegalStateException If the attribute values are unordered and |
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
310 |
* {@code attrVal} is one of those values. |
2 | 311 |
*/ |
312 |
void add(int ix, Object attrVal); |
|
313 |
||
314 |
||
315 |
/** |
|
316 |
* Sets an attribute value in the ordered list of attribute values. |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
317 |
* This method sets the value at the {@code ix} index of the list of |
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
318 |
* attribute values to be {@code attrVal}. The old value is removed. |
2 | 319 |
* If the attribute values are unordered, |
320 |
* this method sets the value that happens to be at that index |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
321 |
* to {@code attrVal}, unless {@code attrVal} is already one of the values. |
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
322 |
* In that case, {@code IllegalStateException} is thrown. |
2 | 323 |
* |
324 |
* @param ix The index of the value in the ordered list of attribute values. |
|
18156 | 325 |
* {@code 0 <= ix < size()}. |
2 | 326 |
* @param attrVal The possibly null attribute value to use. |
327 |
* If null, 'null' replaces the old value. |
|
328 |
* @return The possibly null attribute value at index ix that was replaced. |
|
329 |
* Null if the attribute value was null. |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
330 |
* @exception IndexOutOfBoundsException If {@code ix} is outside the specified range. |
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
331 |
* @exception IllegalStateException If {@code attrVal} already exists and the |
2 | 332 |
* attribute values are unordered. |
333 |
*/ |
|
334 |
Object set(int ix, Object attrVal); |
|
335 |
||
336 |
/** |
|
337 |
* Use serialVersionUID from JNDI 1.1.1 for interoperability. |
|
51437
6221a199ec20
8209304: Deprecate serialVersionUID fields in interfaces
darcy
parents:
51317
diff
changeset
|
338 |
* |
6221a199ec20
8209304: Deprecate serialVersionUID fields in interfaces
darcy
parents:
51317
diff
changeset
|
339 |
* @deprecated A {@code serialVersionUID} field in an interface is |
6221a199ec20
8209304: Deprecate serialVersionUID fields in interfaces
darcy
parents:
51317
diff
changeset
|
340 |
* ineffectual. Do not use; no replacement. |
2 | 341 |
*/ |
51437
6221a199ec20
8209304: Deprecate serialVersionUID fields in interfaces
darcy
parents:
51317
diff
changeset
|
342 |
@Deprecated |
6221a199ec20
8209304: Deprecate serialVersionUID fields in interfaces
darcy
parents:
51317
diff
changeset
|
343 |
@SuppressWarnings("serial") |
2 | 344 |
static final long serialVersionUID = 8707690322213556804L; |
345 |
} |