001/*
002 * Copyright 2008-2017 UnboundID Corp.
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2008-2017 UnboundID Corp.
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU General Public License (GPLv2 only)
010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011 * as published by the Free Software Foundation.
012 *
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program; if not, see <http://www.gnu.org/licenses>.
020 */
021package com.unboundid.ldap.sdk;
022
023
024
025import java.util.Collection;
026
027import com.unboundid.ldap.sdk.schema.Schema;
028import com.unboundid.ldif.LDIFException;
029import com.unboundid.util.NotExtensible;
030import com.unboundid.util.NotMutable;
031import com.unboundid.util.ThreadSafety;
032import com.unboundid.util.ThreadSafetyLevel;
033
034
035
036/**
037 * This class defines an {@link Entry} subclass in which the contents of the
038 * entry cannot be modified.  Any attempt to call a method which could be used
039 * to alter the contents of the entry will result in an
040 * {@link UnsupportedOperationException}.
041 */
042@NotExtensible()
043@NotMutable()
044@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
045public class ReadOnlyEntry
046       extends Entry
047{
048  /**
049   * The serial version UID for this serializable class.
050   */
051  private static final long serialVersionUID = -6482574870325012756L;
052
053
054
055  /**
056   * Creates a new read-only entry with the provided DN and set of attributes.
057   *
058   * @param  dn          The DN for this entry.  It must not be {@code null}.
059   * @param  attributes  The set of attributes for this entry.  It must not be
060   *                     {@code null}.
061   */
062  public ReadOnlyEntry(final String dn, final Attribute... attributes)
063  {
064    this(dn, null, attributes);
065  }
066
067
068
069  /**
070   * Creates a new read-only entry with the provided DN and set of attributes.
071   *
072   * @param  dn          The DN for this entry.  It must not be {@code null}.
073   * @param  schema      The schema to use for operations involving this entry.
074   *                     It may be {@code null} if no schema is available.
075   * @param  attributes  The set of attributes for this entry.  It must not be
076   *                     {@code null}.
077   */
078  public ReadOnlyEntry(final String dn, final Schema schema,
079                       final Attribute... attributes)
080  {
081    super(dn, schema, attributes);
082  }
083
084
085
086  /**
087   * Creates a new read-only entry with the provided DN and set of attributes.
088   *
089   * @param  dn          The DN for this entry.  It must not be {@code null}.
090   * @param  attributes  The set of attributes for this entry.  It must not be
091   *                     {@code null}.
092   */
093  public ReadOnlyEntry(final DN dn, final Attribute... attributes)
094  {
095    this(dn, null, attributes);
096  }
097
098
099
100  /**
101   * Creates a new read-only entry with the provided DN and set of attributes.
102   *
103   * @param  dn          The DN for this entry.  It must not be {@code null}.
104   * @param  schema      The schema to use for operations involving this entry.
105   *                     It may be {@code null} if no schema is available.
106   * @param  attributes  The set of attributes for this entry.  It must not be
107   *                     {@code null}.
108   */
109  public ReadOnlyEntry(final DN dn, final Schema schema,
110                       final Attribute... attributes)
111  {
112    super(dn, schema, attributes);
113  }
114
115
116
117  /**
118   * Creates a new read-only entry with the provided DN and set of attributes.
119   *
120   * @param  dn          The DN for this entry.  It must not be {@code null}.
121   * @param  attributes  The set of attributes for this entry.  It must not be
122   *                     {@code null}.
123   */
124  public ReadOnlyEntry(final String dn, final Collection<Attribute> attributes)
125  {
126    this(dn, null, attributes);
127  }
128
129
130
131  /**
132   * Creates a new read-only entry with the provided DN and set of attributes.
133   *
134   * @param  dn          The DN for this entry.  It must not be {@code null}.
135   * @param  schema      The schema to use for operations involving this entry.
136   *                     It may be {@code null} if no schema is available.
137   * @param  attributes  The set of attributes for this entry.  It must not be
138   *                     {@code null}.
139   */
140  public ReadOnlyEntry(final String dn, final Schema schema,
141                       final Collection<Attribute> attributes)
142  {
143    super(dn, schema, attributes);
144  }
145
146
147
148  /**
149   * Creates a new read-only entry with the provided DN and set of attributes.
150   *
151   * @param  dn          The DN for this entry.  It must not be {@code null}.
152   * @param  attributes  The set of attributes for this entry.  It must not be
153   *                     {@code null}.
154   */
155  public ReadOnlyEntry(final DN dn, final Collection<Attribute> attributes)
156  {
157    this(dn, null, attributes);
158  }
159
160
161
162  /**
163   * Creates a new read-only entry with the provided DN and set of attributes.
164   *
165   * @param  dn          The DN for this entry.  It must not be {@code null}.
166   * @param  schema      The schema to use for operations involving this entry.
167   *                     It may be {@code null} if no schema is available.
168   * @param  attributes  The set of attributes for this entry.  It must not be
169   *                     {@code null}.
170   */
171  public ReadOnlyEntry(final DN dn, final Schema schema,
172                       final Collection<Attribute> attributes)
173  {
174    super(dn, schema, attributes);
175  }
176
177
178
179  /**
180   * Creates a new read-only entry from the provided {@link Entry}.
181   *
182   * @param  entry  The entry to use to create this read-only entry.
183   */
184  public ReadOnlyEntry(final Entry entry)
185  {
186    super(entry);
187  }
188
189
190
191  /**
192   * Creates a new read-only entry from the provided LDIF representation.
193   *
194   * @param  ldifLines  The set of lines that comprise an LDIF representation
195   *                    of the entry.  It must not be {@code null} or empty.
196   *
197   * @throws  LDIFException  If the provided lines cannot be decoded as an entry
198   *                         in LDIF format.
199   */
200  public ReadOnlyEntry(final String... ldifLines)
201         throws LDIFException
202  {
203    this(null, ldifLines);
204  }
205
206
207
208  /**
209   * Creates a new read-only entry from the provided LDIF representation.
210   *
211   * @param  schema     The schema to use for operations involving this entry.
212   *                    It may be {@code null} if no schema is available.
213   * @param  ldifLines  The set of lines that comprise an LDIF representation
214   *                    of the entry.  It must not be {@code null} or empty.
215   *
216   * @throws  LDIFException  If the provided lines cannot be decoded as an entry
217   *                         in LDIF format.
218   */
219  public ReadOnlyEntry(final Schema schema, final String... ldifLines)
220         throws LDIFException
221  {
222    super(schema, ldifLines);
223  }
224
225
226
227  /**
228   * Throws an {@code UnsupportedOperationException} to indicate that this is a
229   * read-only entry.
230   *
231   * @param  dn  The DN for this entry.  It must not be {@code null}.
232   *
233   * @throws  UnsupportedOperationException  To indicate that this is a
234   *                                         read-only entry.
235   */
236  @Override()
237  public void setDN(final String dn)
238         throws UnsupportedOperationException
239  {
240    throw new UnsupportedOperationException();
241  }
242
243
244
245  /**
246   * Throws an {@code UnsupportedOperationException} to indicate that this is a
247   * read-only entry.
248   *
249   * @param  dn  The DN for this entry.  It must not be {@code null}.
250   *
251   * @throws  UnsupportedOperationException  To indicate that this is a
252   *                                         read-only entry.
253   */
254  @Override()
255  public void setDN(final DN dn)
256         throws UnsupportedOperationException
257  {
258    throw new UnsupportedOperationException();
259  }
260
261
262
263  /**
264   * Throws an {@code UnsupportedOperationException} to indicate that this is a
265   * read-only entry.
266   *
267   * @param  attribute  The attribute to be added.  It must not be {@code null}.
268   *
269   * @return  This method will never return successfully.
270   *
271   * @throws  UnsupportedOperationException  To indicate that this is a
272   *                                         read-only entry.
273   */
274  @Override()
275  public boolean addAttribute(final Attribute attribute)
276         throws UnsupportedOperationException
277  {
278    throw new UnsupportedOperationException();
279  }
280
281
282
283  /**
284   * Throws an {@code UnsupportedOperationException} to indicate that this is a
285   * read-only entry.
286   *
287   * @param  attributeName   The name for the attribute to be added.  It must
288   *                         not be {@code null}.
289   * @param  attributeValue  The value for the attribute to be added.  It must
290   *                         not be {@code null}.
291   *
292   * @return  This method will never return successfully.
293   *
294   * @throws  UnsupportedOperationException  To indicate that this is a
295   *                                         read-only entry.
296   */
297  @Override()
298  public boolean addAttribute(final String attributeName,
299                              final String attributeValue)
300         throws UnsupportedOperationException
301  {
302    throw new UnsupportedOperationException();
303  }
304
305
306
307  /**
308   * Throws an {@code UnsupportedOperationException} to indicate that this is a
309   * read-only entry.
310   *
311   * @param  attributeName   The name for the attribute to be added.  It must
312   *                         not be {@code null}.
313   * @param  attributeValue  The value for the attribute to be added.  It must
314   *                         not be {@code null}.
315   *
316   * @return  This method will never return successfully.
317   *
318   * @throws  UnsupportedOperationException  To indicate that this is a
319   *                                         read-only entry.
320   */
321  @Override()
322  public boolean addAttribute(final String attributeName,
323                              final byte[] attributeValue)
324         throws UnsupportedOperationException
325  {
326    throw new UnsupportedOperationException();
327  }
328
329
330
331  /**
332   * Throws an {@code UnsupportedOperationException} to indicate that this is a
333   * read-only entry.
334   *
335   * @param  attributeName    The name for the attribute to be added.  It must
336   *                          not be {@code null}.
337   * @param  attributeValues  The set of values for the attribute to be added.
338   *                          It must not be {@code null}.
339   *
340   * @return  This method will never return successfully.
341   *
342   * @throws  UnsupportedOperationException  To indicate that this is a
343   *                                         read-only entry.
344   */
345  @Override()
346  public boolean addAttribute(final String attributeName,
347                              final String... attributeValues)
348         throws UnsupportedOperationException
349  {
350    throw new UnsupportedOperationException();
351  }
352
353
354
355  /**
356   * Throws an {@code UnsupportedOperationException} to indicate that this is a
357   * read-only entry.
358   *
359   * @param  attributeName    The name for the attribute to be added.  It must
360   *                          not be {@code null}.
361   * @param  attributeValues  The set of values for the attribute to be added.
362   *                          It must not be {@code null}.
363   *
364   * @return  This method will never return successfully.
365   *
366   * @throws  UnsupportedOperationException  To indicate that this is a
367   *                                         read-only entry.
368   */
369  @Override()
370  public boolean addAttribute(final String attributeName,
371                              final byte[]... attributeValues)
372         throws UnsupportedOperationException
373  {
374    throw new UnsupportedOperationException();
375  }
376
377
378
379  /**
380   * Throws an {@code UnsupportedOperationException} to indicate that this is a
381   * read-only entry.
382   *
383   * @param  attributeName  The name of the attribute to remove.  It must not be
384   *                        {@code null}.
385   *
386   * @return  This method will never return successfully.
387   *
388   * @throws  UnsupportedOperationException  To indicate that this is a
389   *                                         read-only entry.
390   */
391  @Override()
392  public boolean removeAttribute(final String attributeName)
393         throws UnsupportedOperationException
394  {
395    throw new UnsupportedOperationException();
396  }
397
398
399
400  /**
401   * Throws an {@code UnsupportedOperationException} to indicate that this is a
402   * read-only entry.
403   *
404   * @param  attributeName   The name of the attribute to remove.  It must not
405   *                         be {@code null}.
406   * @param  attributeValue  The value of the attribute to remove.  It must not
407   *                         be {@code null}.
408   *
409   * @return  This method will never return successfully.
410   *
411   * @throws  UnsupportedOperationException  To indicate that this is a
412   *                                         read-only entry.
413   */
414  @Override()
415  public boolean removeAttributeValue(final String attributeName,
416                                      final String attributeValue)
417         throws UnsupportedOperationException
418  {
419    throw new UnsupportedOperationException();
420  }
421
422
423
424  /**
425   * Throws an {@code UnsupportedOperationException} to indicate that this is a
426   * read-only entry.
427   *
428   * @param  attributeName   The name of the attribute to remove.  It must not
429   *                         be {@code null}.
430   * @param  attributeValue  The value of the attribute to remove.  It must not
431   *                         be {@code null}.
432   *
433   * @return  This method will never return successfully.
434   *
435   * @throws  UnsupportedOperationException  To indicate that this is a
436   *                                         read-only entry.
437   */
438  @Override()
439  public boolean removeAttributeValue(final String attributeName,
440                                      final byte[] attributeValue)
441         throws UnsupportedOperationException
442  {
443    throw new UnsupportedOperationException();
444  }
445
446
447
448  /**
449   * Throws an {@code UnsupportedOperationException} to indicate that this is a
450   * read-only entry.
451   *
452   * @param  attributeName    The name of the attribute to remove.  It must not
453   *                          be {@code null}.
454   * @param  attributeValues  The values of the attribute to remove.  It must
455   *                          not be {@code null}.
456   *
457   * @return  This method will never return successfully.
458   *
459   * @throws  UnsupportedOperationException  To indicate that this is a
460   *                                         read-only entry.
461   */
462  @Override()
463  public boolean removeAttributeValues(final String attributeName,
464                                       final String... attributeValues)
465         throws UnsupportedOperationException
466  {
467    throw new UnsupportedOperationException();
468  }
469
470
471
472  /**
473   * Throws an {@code UnsupportedOperationException} to indicate that this is a
474   * read-only entry.
475   *
476   * @param  attributeName    The name of the attribute to remove.  It must not
477   *                          be {@code null}.
478   * @param  attributeValues  The values of the attribute to remove.  It must
479   *                          not be {@code null}.
480   *
481   * @return  This method will never return successfully.
482   *
483   * @throws  UnsupportedOperationException  To indicate that this is a
484   *                                         read-only entry.
485   */
486  @Override()
487  public boolean removeAttributeValues(final String attributeName,
488                                       final byte[]... attributeValues)
489         throws UnsupportedOperationException
490  {
491    throw new UnsupportedOperationException();
492  }
493
494
495
496  /**
497   * Throws an {@code UnsupportedOperationException} to indicate that this is a
498   * read-only entry.
499   *
500   * @param  attribute  The attribute to be included in this entry.  It must not
501   *                    be {@code null}.
502   *
503   * @throws  UnsupportedOperationException  To indicate that this is a
504   *                                         read-only entry.
505   */
506  @Override()
507  public void setAttribute(final Attribute attribute)
508         throws UnsupportedOperationException
509  {
510    throw new UnsupportedOperationException();
511  }
512
513
514
515  /**
516   * Throws an {@code UnsupportedOperationException} to indicate that this is a
517   * read-only entry.
518   *
519   * @param  attributeName   The name to use for the attribute.  It must not be
520   *                         {@code null}.
521   * @param  attributeValue  The value to use for the attribute.  It must not be
522   *                         {@code null}.
523   *
524   * @throws  UnsupportedOperationException  To indicate that this is a
525   *                                         read-only entry.
526   */
527  @Override()
528  public void setAttribute(final String attributeName,
529                           final String attributeValue)
530         throws UnsupportedOperationException
531  {
532    throw new UnsupportedOperationException();
533  }
534
535
536
537  /**
538   * Throws an {@code UnsupportedOperationException} to indicate that this is a
539   * read-only entry.
540   *
541   * @param  attributeName   The name to use for the attribute.  It must not be
542   *                         {@code null}.
543   * @param  attributeValue  The value to use for the attribute.  It must not be
544   *                         {@code null}.
545   *
546   * @throws  UnsupportedOperationException  To indicate that this is a
547   *                                         read-only entry.
548   */
549  @Override()
550  public void setAttribute(final String attributeName,
551                           final byte[] attributeValue)
552         throws UnsupportedOperationException
553  {
554    throw new UnsupportedOperationException();
555  }
556
557
558
559  /**
560   * Throws an {@code UnsupportedOperationException} to indicate that this is a
561   * read-only entry.
562   *
563   * @param  attributeName    The name to use for the attribute.  It must not be
564   *                          {@code null}.
565   * @param  attributeValues  The set of values to use for the attribute.  It
566   *                          must not be {@code null}.
567   *
568   * @throws  UnsupportedOperationException  To indicate that this is a
569   *                                         read-only entry.
570   */
571  @Override()
572  public void setAttribute(final String attributeName,
573                           final String... attributeValues)
574         throws UnsupportedOperationException
575  {
576    throw new UnsupportedOperationException();
577  }
578
579
580
581  /**
582   * Throws an {@code UnsupportedOperationException} to indicate that this is a
583   * read-only entry.
584   *
585   * @param  attributeName    The name to use for the attribute.  It must not be
586   *                          {@code null}.
587   * @param  attributeValues  The set of values to use for the attribute.  It
588   *                          must not be {@code null}.
589   *
590   * @throws  UnsupportedOperationException  To indicate that this is a
591   *                                         read-only entry.
592   */
593  @Override()
594  public void setAttribute(final String attributeName,
595                           final byte[]... attributeValues)
596         throws UnsupportedOperationException
597  {
598    throw new UnsupportedOperationException();
599  }
600}