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