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