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