mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Ludovic Poitou
14.52.2010 72650d4cc41c64136d064967d7fec3726d850fee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 */
 
package org.opends.sdk;
 
 
 
import java.util.Collection;
 
 
 
/**
 * An entry, comprising of a distinguished name and zero or more attributes.
 * <p>
 * Some methods require a schema in order to decode their parameters (e.g.
 * {@link #addAttribute(String, Object...)} and {@link #setName(String)}). In
 * these cases the default schema is used unless an alternative schema is
 * specified in the {@code Entry} constructor. The default schema is not used
 * for any other purpose. In particular, an {@code Entry} will permit attributes
 * to be added which have been decoded using multiple schemas.
 * <p>
 * Full LDAP modify semantics are provided via the {@link #addAttribute},
 * {@link #removeAttribute}, and {@link #replaceAttribute} methods.
 * <p>
 * Implementations should specify any constraints or special behavior.
 * Specifically:
 * <ul>
 * <li>Which methods are supported.
 * <li>The order in which attributes are returned using the
 * {@link #getAllAttributes()} method.
 * <li>How existing attributes are modified during calls to
 * {@link #addAttribute}, {@link #removeAttribute}, and
 * {@link #replaceAttribute} and the conditions, if any, where a reference to
 * the passed in attribute is maintained.
 * </ul>
 *
 * @see Entries
 */
public interface Entry
{
 
  /**
   * Ensures that this entry contains the provided attribute and values
   * (optional operation). This method has the following semantics:
   * <ul>
   * <li>If this entry does not already contain an attribute with the same
   * attribute description, then this entry will be modified such that it
   * contains {@code attribute}, even if it is empty.
   * <li>If this entry already contains an attribute with the same attribute
   * description, then the attribute values contained in {@code attribute} will
   * be merged with the existing attribute values.
   * </ul>
   * <p>
   * <b>NOTE:</b> When {@code attribute} is non-empty, this method implements
   * LDAP Modify add semantics.
   *
   * @param attribute
   *          The attribute values to be added to this entry, merging with any
   *          existing attribute values.
   * @return {@code true} if this entry changed as a result of this call.
   * @throws UnsupportedOperationException
   *           If this entry does not permit attributes or their values to be
   *           added.
   * @throws NullPointerException
   *           If {@code attribute} was {@code null}.
   */
  boolean addAttribute(Attribute attribute)
      throws UnsupportedOperationException, NullPointerException;
 
 
 
  /**
   * Ensures that this entry contains the provided attribute and values
   * (optional operation). This method has the following semantics:
   * <ul>
   * <li>If this entry does not already contain an attribute with the same
   * attribute description, then this entry will be modified such that it
   * contains {@code attribute}, even if it is empty.
   * <li>If this entry already contains an attribute with the same attribute
   * description, then the attribute values contained in {@code attribute} will
   * be merged with the existing attribute values.
   * </ul>
   * <p>
   * <b>NOTE:</b> When {@code attribute} is non-empty, this method implements
   * LDAP Modify add semantics.
   *
   * @param attribute
   *          The attribute values to be added to this entry, merging with any
   *          existing attribute values.
   * @param duplicateValues
   *          A collection into which duplicate values will be added, or {@code
   *          null} if duplicate values should not be saved.
   * @return {@code true} if this entry changed as a result of this call.
   * @throws UnsupportedOperationException
   *           If this entry does not permit attributes or their values to be
   *           added.
   * @throws NullPointerException
   *           If {@code attribute} was {@code null}.
   */
  boolean addAttribute(Attribute attribute,
      Collection<ByteString> duplicateValues)
      throws UnsupportedOperationException, NullPointerException;
 
 
 
  /**
   * Ensures that this entry contains the provided attribute and values
   * (optional operation). This method has the following semantics:
   * <ul>
   * <li>If this entry does not already contain an attribute with the same
   * attribute description, then this entry will be modified such that it
   * contains {@code attribute}, even if it is empty.
   * <li>If this entry already contains an attribute with the same attribute
   * description, then the attribute values contained in {@code attribute} will
   * be merged with the existing attribute values.
   * </ul>
   * <p>
   * The attribute description will be decoded using the schema associated with
   * this entry (usually the default schema).
   * <p>
   * Any attribute values which are not instances of {@code ByteString} will be
   * converted using the {@link ByteString#valueOf(Object)} method.
   * <p>
   * <b>NOTE:</b> When {@code attribute} is non-empty, this method implements
   * LDAP Modify add semantics.
   *
   * @param attributeDescription
   *          The name of the attribute whose values are to be added.
   * @param values
   *          The attribute values to be added to this entry, merging any
   *          existing attribute values.
   * @return This entry.
   * @throws LocalizedIllegalArgumentException
   *           If {@code attributeDescription} could not be decoded using the
   *           schema associated with this entry.
   * @throws UnsupportedOperationException
   *           If this entry does not permit attributes or their values to be
   *           added.
   * @throws NullPointerException
   *           If {@code attributeDescription} was {@code null}.
   */
  Entry addAttribute(String attributeDescription, Object... values)
      throws LocalizedIllegalArgumentException, UnsupportedOperationException,
      NullPointerException;
 
 
 
  /**
   * Removes all the attributes from this entry (optional operation).
   *
   * @return This entry.
   * @throws UnsupportedOperationException
   *           If this entry does not permit attributes to be removed.
   */
  Entry clearAttributes() throws UnsupportedOperationException;
 
 
 
  /**
   * Returns {@code true} if this entry contains all of the attribute values
   * contained in {@code attribute}. If {@code attribute} is empty then this
   * method will return {@code true} if the attribute is present in this entry,
   * regardless of how many values it contains.
   *
   * @param attribute
   *          The attribute values whose presence in this entry is to be tested.
   * @param missingValues
   *          A collection into which missing values will be added, or {@code
   *          null} if missing values should not be saved.
   * @return {@code true} if this entry contains all of the attribute values
   *         contained in {@code attribute}.
   * @throws NullPointerException
   *           If {@code attribute} was {@code null}.
   */
  boolean containsAttribute(Attribute attribute,
      Collection<ByteString> missingValues) throws NullPointerException;
 
 
 
  /**
   * Returns {@code true} if this entry contains all of the attribute values
   * contained in {@code values}. If {@code values} is {@code null} or empty
   * then this method will return {@code true} if the attribute is present in
   * this entry, regardless of how many values it contains.
   * <p>
   * The attribute description will be decoded using the schema associated with
   * this entry (usually the default schema).
   * <p>
   * Any attribute values which are not instances of {@code ByteString} will be
   * converted using the {@link ByteString#valueOf(Object)} method.
   *
   * @param attributeDescription
   *          The name of the attribute whose presence in this entry is to be
   *          tested.
   * @param values
   *          The attribute values whose presence in this entry is to be tested,
   *          which may be {@code null}.
   * @return {@code true} if this entry contains all of the attribute values
   *         contained in {@code values}.
   * @throws LocalizedIllegalArgumentException
   *           If {@code attributeDescription} could not be decoded using the
   *           schema associated with this entry.
   * @throws NullPointerException
   *           If {@code attributeDescription} was {@code null}.
   */
  boolean containsAttribute(String attributeDescription, Object... values)
      throws LocalizedIllegalArgumentException, NullPointerException;
 
 
 
  /**
   * Returns {@code true} if {@code object} is an entry which is equal to this
   * entry. Two entries are considered equal if their distinguished names are
   * equal, they both have the same number of attributes, and every attribute
   * contained in the first entry is also contained in the second entry.
   *
   * @param object
   *          The object to be tested for equality with this entry.
   * @return {@code true} if {@code object} is an entry which is equal to this
   *         entry, or {@code false} if not.
   */
  boolean equals(Object object);
 
 
 
  /**
   * Returns an {@code Iterable} containing all of the attributes in this entry.
   * The returned {@code Iterable} may be used to remove attributes if permitted
   * by this entry.
   *
   * @return An {@code Iterable} containing all of the attributes.
   */
  Iterable<Attribute> getAllAttributes();
 
 
 
  /**
   * Returns an {@code Iterable} containing all the attributes in this entry
   * having an attribute description which is a sub-type of the provided
   * attribute description. The returned {@code Iterable} may be used to remove
   * attributes if permitted by this entry.
   *
   * @param attributeDescription
   *          The name of the attributes to be returned.
   * @return An {@code Iterable} containing the matching attributes.
   * @throws NullPointerException
   *           If {@code attributeDescription} was {@code null}.
   */
  Iterable<Attribute> getAllAttributes(AttributeDescription attributeDescription)
      throws NullPointerException;
 
 
 
  /**
   * Returns an {@code Iterable} containing all the attributes in this entry
   * having an attribute description which is a sub-type of the provided
   * attribute description. The returned {@code Iterable} may be used to remove
   * attributes if permitted by this entry.
   * <p>
   * The attribute description will be decoded using the schema associated with
   * this entry (usually the default schema).
   *
   * @param attributeDescription
   *          The name of the attributes to be returned.
   * @return An {@code Iterable} containing the matching attributes.
   * @throws LocalizedIllegalArgumentException
   *           If {@code attributeDescription} could not be decoded using the
   *           schema associated with this entry.
   * @throws NullPointerException
   *           If {@code attributeDescription} was {@code null}.
   */
  Iterable<Attribute> getAllAttributes(String attributeDescription)
      throws LocalizedIllegalArgumentException, NullPointerException;
 
 
 
  /**
   * Returns the named attribute contained in this entry, or {@code null} if it
   * is not included with this entry.
   *
   * @param attributeDescription
   *          The name of the attribute to be returned.
   * @return The named attribute, or {@code null} if it is not included with
   *         this entry.
   * @throws NullPointerException
   *           If {@code attributeDescription} was {@code null}.
   */
  Attribute getAttribute(AttributeDescription attributeDescription)
      throws NullPointerException;
 
 
 
  /**
   * Returns the named attribute contained in this entry, or {@code null} if it
   * is not included with this entry.
   * <p>
   * The attribute description will be decoded using the schema associated with
   * this entry (usually the default schema).
   *
   * @param attributeDescription
   *          The name of the attribute to be returned.
   * @return The named attribute, or {@code null} if it is not included with
   *         this entry.
   * @throws LocalizedIllegalArgumentException
   *           If {@code attributeDescription} could not be decoded using the
   *           schema associated with this entry.
   * @throws NullPointerException
   *           If {@code attributeDescription} was {@code null}.
   */
  Attribute getAttribute(String attributeDescription)
      throws LocalizedIllegalArgumentException, NullPointerException;
 
 
 
  /**
   * Returns the number of attributes in this entry.
   *
   * @return The number of attributes.
   */
  int getAttributeCount();
 
 
 
  /**
   * Returns the string representation of the distinguished name of this entry.
   *
   * @return The string representation of the distinguished name.
   */
  DN getName();
 
 
 
  /**
   * Returns the hash code for this entry. It will be calculated as the sum of
   * the hash codes of the distinguished name and all of the attributes.
   *
   * @return The hash code for this entry.
   */
  int hashCode();
 
 
 
  /**
   * Removes all of the attribute values contained in {@code attribute} from
   * this entry if it is present (optional operation). If {@code attribute} is
   * empty then the entire attribute will be removed if it is present.
   * <p>
   * <b>NOTE:</b> This method implements LDAP Modify delete semantics.
   *
   * @param attribute
   *          The attribute values to be removed from this entry, which may be
   *          empty if the entire attribute is to be removed.
   * @param missingValues
   *          A collection into which missing values will be added, or {@code
   *          null} if missing values should not be saved.
   * @return {@code true} if this entry changed as a result of this call.
   * @throws UnsupportedOperationException
   *           If this entry does not permit attributes or their values to be
   *           removed.
   * @throws NullPointerException
   *           If {@code attribute} was {@code null}.
   */
  boolean removeAttribute(Attribute attribute,
      Collection<ByteString> missingValues)
      throws UnsupportedOperationException, NullPointerException;
 
 
 
  /**
   * Removes the named attribute from this entry if it is present (optional
   * operation). If this attribute does not contain the attribute, the call
   * leaves this entry unchanged and returns {@code false}.
   *
   * @param attributeDescription
   *          The name of the attribute to be removed.
   * @return {@code true} if this entry changed as a result of this call.
   * @throws UnsupportedOperationException
   *           If this entry does not permit attributes to be removed.
   * @throws NullPointerException
   *           If {@code attributeDescription} was {@code null}.
   */
  boolean removeAttribute(AttributeDescription attributeDescription)
      throws UnsupportedOperationException, NullPointerException;
 
 
 
  /**
   * Removes all of the attribute values contained in {@code values} from the
   * named attribute in this entry if it is present (optional operation). If
   * {@code values} is {@code null} or empty then the entire attribute will be
   * removed if it is present.
   * <p>
   * The attribute description will be decoded using the schema associated with
   * this entry (usually the default schema).
   * <p>
   * Any attribute values which are not instances of {@code ByteString} will be
   * converted using the {@link ByteString#valueOf(Object)} method.
   * <p>
   * <b>NOTE:</b> This method implements LDAP Modify delete semantics.
   *
   * @param attributeDescription
   *          The name of the attribute whose values are to be removed.
   * @param values
   *          The attribute values to be removed from this entry, which may be
   *          {@code null} or empty if the entire attribute is to be removed.
   * @return This entry.
   * @throws LocalizedIllegalArgumentException
   *           If {@code attributeDescription} could not be decoded using the
   *           schema associated with this entry.
   * @throws UnsupportedOperationException
   *           If this entry does not permit attributes or their values to be
   *           removed.
   * @throws NullPointerException
   *           If {@code attributeDescription} was {@code null}.
   */
  Entry removeAttribute(String attributeDescription, Object... values)
      throws LocalizedIllegalArgumentException, UnsupportedOperationException,
      NullPointerException;
 
 
 
  /**
   * Adds all of the attribute values contained in {@code attribute} to this
   * entry, replacing any existing attribute values (optional operation). If
   * {@code attribute} is empty then the entire attribute will be removed if it
   * is present.
   * <p>
   * <b>NOTE:</b> This method implements LDAP Modify replace semantics.
   *
   * @param attribute
   *          The attribute values to be added to this entry, replacing any
   *          existing attribute values, and which may be empty if the entire
   *          attribute is to be removed.
   * @return {@code true} if this entry changed as a result of this call.
   * @throws UnsupportedOperationException
   *           If this entry does not permit attributes or their values to be
   *           replaced.
   * @throws NullPointerException
   *           If {@code attribute} was {@code null}.
   */
  boolean replaceAttribute(Attribute attribute)
      throws UnsupportedOperationException, NullPointerException;
 
 
 
  /**
   * Adds all of the attribute values contained in {@code values} to this entry,
   * replacing any existing attribute values (optional operation). If {@code
   * values} is {@code null} or empty then the entire attribute will be removed
   * if it is present.
   * <p>
   * The attribute description will be decoded using the schema associated with
   * this entry (usually the default schema).
   * <p>
   * Any attribute values which are not instances of {@code ByteString} will be
   * converted using the {@link ByteString#valueOf(Object)} method.
   * <p>
   * <b>NOTE:</b> This method implements LDAP Modify replace semantics.
   *
   * @param attributeDescription
   *          The name of the attribute whose values are to be replaced.
   * @param values
   *          The attribute values to be added to this entry, replacing any
   *          existing attribute values, and which may be {@code null} or empty
   *          if the entire attribute is to be removed.
   * @return This entry.
   * @throws LocalizedIllegalArgumentException
   *           If {@code attributeDescription} could not be decoded using the
   *           schema associated with this entry.
   * @throws UnsupportedOperationException
   *           If this entry does not permit attributes or their values to be
   *           replaced.
   * @throws NullPointerException
   *           If {@code attribute} was {@code null}.
   */
  Entry replaceAttribute(String attributeDescription, Object... values)
      throws LocalizedIllegalArgumentException, UnsupportedOperationException,
      NullPointerException;
 
 
 
  /**
   * Sets the distinguished name of this entry (optional operation).
   *
   * @param dn
   *          The distinguished name.
   * @return This entry.
   * @throws UnsupportedOperationException
   *           If this entry does not permit the distinguished name to be set.
   * @throws NullPointerException
   *           If {@code dn} was {@code null}.
   */
  Entry setName(DN dn) throws UnsupportedOperationException,
      NullPointerException;
 
 
 
  /**
   * Sets the distinguished name of this entry (optional operation).
   * <p>
   * The distinguished name will be decoded using the schema associated with
   * this entry (usually the default schema).
   *
   * @param dn
   *          The string representation of the distinguished name.
   * @return This entry.
   * @throws LocalizedIllegalArgumentException
   *           If {@code dn} could not be decoded using the schema associated
   *           with this entry.
   * @throws UnsupportedOperationException
   *           If this entry does not permit the distinguished name to be set.
   * @throws NullPointerException
   *           If {@code dn} was {@code null}.
   */
  Entry setName(String dn) throws LocalizedIllegalArgumentException,
      UnsupportedOperationException, NullPointerException;
 
 
 
  /**
   * Returns a string representation of this entry.
   *
   * @return The string representation of this entry.
   */
  String toString();
}