From 887e246785056b972a725b5ef8457980325216fb Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Fri, 22 Oct 2010 07:03:51 +0000
Subject: [PATCH] Sync commits from boli Added unmodifiable and copyOf response factories. Made LinkedHashMapEntry copy constructor perform a deep copy of attributes.

---
 sdk/src/org/opends/sdk/responses/UnmodifiableGenericExtendedResultImpl.java        |   54 ++
 sdk/src/org/opends/sdk/responses/WhoAmIExtendedResultImpl.java                     |   20 
 sdk/src/org/opends/sdk/responses/AbstractUnmodifiableResultImpl.java               |    7 
 sdk/src/org/opends/sdk/responses/UnmodifiableBindResultImpl.java                   |   57 ++
 sdk/src/org/opends/sdk/responses/SearchResultEntryImpl.java                        |   22 
 sdk/src/org/opends/sdk/responses/UnmodifiableCompareResultImpl.java                |   45 +
 sdk/src/org/opends/sdk/LinkedHashMapEntry.java                                     |    4 
 sdk/src/org/opends/sdk/responses/AbstractIntermediateResponseImpl.java             |   24 
 sdk/src/org/opends/sdk/responses/AbstractUnmodifiableExtendedResultImpl.java       |   60 ++
 sdk/src/org/opends/sdk/responses/AbstractExtendedResultImpl.java                   |   25 
 sdk/src/org/opends/sdk/responses/GenericExtendedResultImpl.java                    |   29 
 sdk/src/org/opends/sdk/responses/UnmodifiableSearchResultEntryImpl.java            |  196 ++++++++
 sdk/src/org/opends/sdk/responses/CompareResultImpl.java                            |   17 
 sdk/src/org/opends/sdk/responses/GenericIntermediateResponseImpl.java              |   22 
 sdk/src/com/sun/opends/sdk/extensions/PasswordPolicyStateExtendedResult.java       |    4 
 sdk/src/org/opends/sdk/responses/UnmodifiableSearchResultReferenceImpl.java        |   53 ++
 sdk/src/org/opends/sdk/responses/UnmodifiablePasswordModifyExtendedResultImpl.java |   66 ++
 sdk/src/org/opends/sdk/responses/AbstractUnmodifiableIntermediateResponseImpl.java |   61 ++
 sdk/src/org/opends/sdk/responses/ResultImpl.java                                   |   17 
 sdk/src/org/opends/sdk/responses/Responses.java                                    |  344 ++++++++++++++
 sdk/src/org/opends/sdk/responses/BindResultImpl.java                               |   20 
 sdk/src/org/opends/sdk/responses/AbstractResultImpl.java                           |   23 
 sdk/src/org/opends/sdk/responses/UnmodifiableResultImpl.java                       |   39 +
 sdk/src/org/opends/sdk/responses/SearchResultReferenceImpl.java                    |   20 
 sdk/src/com/sun/opends/sdk/extensions/GetConnectionIDExtendedResult.java           |    7 
 sdk/src/org/opends/sdk/responses/AbstractUnmodifiableResponseImpl.java             |    6 
 sdk/src/org/opends/sdk/responses/PasswordModifyExtendedResultImpl.java             |   29 +
 sdk/src/org/opends/sdk/responses/UnmodifiableGenericIntermediateResponseImpl.java  |   55 ++
 sdk/src/org/opends/sdk/responses/WhoAmIExtendedResult.java                         |    5 
 sdk/src/org/opends/sdk/responses/UnmodifiableWhoAmIExtendedResultImpl.java         |   53 ++
 sdk/src/org/opends/sdk/responses/PasswordModifyExtendedResult.java                 |   12 
 sdk/src/org/opends/sdk/responses/AbstractResponseImpl.java                         |   20 
 32 files changed, 1,363 insertions(+), 53 deletions(-)

diff --git a/sdk/src/com/sun/opends/sdk/extensions/GetConnectionIDExtendedResult.java b/sdk/src/com/sun/opends/sdk/extensions/GetConnectionIDExtendedResult.java
index 9228497..1992c59 100644
--- a/sdk/src/com/sun/opends/sdk/extensions/GetConnectionIDExtendedResult.java
+++ b/sdk/src/com/sun/opends/sdk/extensions/GetConnectionIDExtendedResult.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2009 Sun Microsystems, Inc.
+ *      Copyright 2010 Sun Microsystems, Inc.
  */
 
 package com.sun.opends.sdk.extensions;
@@ -36,19 +36,18 @@
 import org.opends.sdk.ResultCode;
 import org.opends.sdk.asn1.ASN1;
 import org.opends.sdk.asn1.ASN1Writer;
-import org.opends.sdk.responses.AbstractExtendedResult;
+import org.opends.sdk.responses.AbstractExtendedResultImpl;
 
 import com.sun.opends.sdk.util.Validator;
 
 
-
 /**
  * Get connection ID extended result.
  *
  * @see GetConnectionIDExtendedRequest
  */
 public final class GetConnectionIDExtendedResult extends
-    AbstractExtendedResult<GetConnectionIDExtendedResult>
+    AbstractExtendedResultImpl<GetConnectionIDExtendedResult>
 {
   /**
    * Creates a new get connection ID extended result.
diff --git a/sdk/src/com/sun/opends/sdk/extensions/PasswordPolicyStateExtendedResult.java b/sdk/src/com/sun/opends/sdk/extensions/PasswordPolicyStateExtendedResult.java
index 2bb5f5f..9e8df68 100644
--- a/sdk/src/com/sun/opends/sdk/extensions/PasswordPolicyStateExtendedResult.java
+++ b/sdk/src/com/sun/opends/sdk/extensions/PasswordPolicyStateExtendedResult.java
@@ -35,7 +35,7 @@
 import org.opends.sdk.ByteString;
 import org.opends.sdk.DN;
 import org.opends.sdk.ResultCode;
-import org.opends.sdk.responses.AbstractExtendedResult;
+import org.opends.sdk.responses.AbstractExtendedResultImpl;
 
 
 
@@ -43,7 +43,7 @@
  * The password policy state extended result.
  */
 public final class PasswordPolicyStateExtendedResult extends
-    AbstractExtendedResult<PasswordPolicyStateExtendedResult> implements
+    AbstractExtendedResultImpl<PasswordPolicyStateExtendedResult> implements
     PasswordPolicyStateOperationContainer
 {
   private final String targetUser;
diff --git a/sdk/src/org/opends/sdk/LinkedHashMapEntry.java b/sdk/src/org/opends/sdk/LinkedHashMapEntry.java
index 2cee13a..9ddd0e9 100644
--- a/sdk/src/org/opends/sdk/LinkedHashMapEntry.java
+++ b/sdk/src/org/opends/sdk/LinkedHashMapEntry.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2009 Sun Microsystems, Inc.
+ *      Copyright 2010 Sun Microsystems, Inc.
  */
 
 package org.opends.sdk;
@@ -109,7 +109,7 @@
     this(entry.getName());
     for (final Attribute attribute : entry.getAllAttributes())
     {
-      addAttribute(attribute);
+      addAttribute(new LinkedAttribute(attribute));
     }
   }
 
diff --git a/sdk/src/org/opends/sdk/responses/AbstractExtendedResult.java b/sdk/src/org/opends/sdk/responses/AbstractExtendedResultImpl.java
similarity index 79%
rename from sdk/src/org/opends/sdk/responses/AbstractExtendedResult.java
rename to sdk/src/org/opends/sdk/responses/AbstractExtendedResultImpl.java
index 339ac92..e81944f 100644
--- a/sdk/src/org/opends/sdk/responses/AbstractExtendedResult.java
+++ b/sdk/src/org/opends/sdk/responses/AbstractExtendedResultImpl.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2009 Sun Microsystems, Inc.
+ *      Copyright 2010 Sun Microsystems, Inc.
  */
 
 package org.opends.sdk.responses;
@@ -43,8 +43,8 @@
  * @param <S>
  *          The type of Extended result.
  */
-public abstract class AbstractExtendedResult<S extends ExtendedResult> extends
-    AbstractResultImpl<S> implements ExtendedResult
+public abstract class AbstractExtendedResultImpl<S extends ExtendedResult>
+    extends AbstractResultImpl<S> implements ExtendedResult
 {
 
   /**
@@ -55,7 +55,7 @@
    * @throws NullPointerException
    *           If {@code resultCode} was {@code null}.
    */
-  protected AbstractExtendedResult(final ResultCode resultCode)
+  protected AbstractExtendedResultImpl(final ResultCode resultCode)
       throws NullPointerException
   {
     super(resultCode);
@@ -64,6 +64,23 @@
 
 
   /**
+   * Creates a new extended result that is an exact copy of the provided
+   * result.
+   *
+   * @param extendedResult
+   *          The extended result to be copied.
+   * @throws NullPointerException
+   *           If {@code extendedResult} was {@code null} .
+   */
+  protected AbstractExtendedResultImpl(ExtendedResult extendedResult)
+      throws NullPointerException
+  {
+    super(extendedResult);
+  }
+
+
+
+  /**
    * {@inheritDoc}
    */
   public abstract String getOID();
diff --git a/sdk/src/org/opends/sdk/responses/AbstractIntermediateResponse.java b/sdk/src/org/opends/sdk/responses/AbstractIntermediateResponseImpl.java
similarity index 77%
rename from sdk/src/org/opends/sdk/responses/AbstractIntermediateResponse.java
rename to sdk/src/org/opends/sdk/responses/AbstractIntermediateResponseImpl.java
index fc6333a..c7ef0d1 100644
--- a/sdk/src/org/opends/sdk/responses/AbstractIntermediateResponse.java
+++ b/sdk/src/org/opends/sdk/responses/AbstractIntermediateResponseImpl.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2009 Sun Microsystems, Inc.
+ *      Copyright 2010 Sun Microsystems, Inc.
  */
 
 package org.opends.sdk.responses;
@@ -42,14 +42,14 @@
  * @param <S>
  *          The type of Intermediate response.
  */
-public abstract class AbstractIntermediateResponse<S extends IntermediateResponse>
+public abstract class AbstractIntermediateResponseImpl<S extends IntermediateResponse>
     extends AbstractResponseImpl<S> implements IntermediateResponse
 {
 
   /**
    * Creates a new intermediate response.
    */
-  protected AbstractIntermediateResponse()
+  protected AbstractIntermediateResponseImpl()
   {
     // Nothing to do.
   }
@@ -57,6 +57,24 @@
 
 
   /**
+   * Creates a new intermediate response that is an exact copy of the provided
+   * response.
+   *
+   * @param intermediateResponse
+   *          The intermediate response to be copied.
+   * @throws NullPointerException
+   *           If {@code intermediateResponse} was {@code null} .
+   */
+  protected AbstractIntermediateResponseImpl(
+      IntermediateResponse intermediateResponse)
+      throws NullPointerException
+  {
+    super(intermediateResponse);
+  }
+
+
+
+  /**
    * {@inheritDoc}
    */
   public abstract String getOID();
diff --git a/sdk/src/org/opends/sdk/responses/AbstractResponseImpl.java b/sdk/src/org/opends/sdk/responses/AbstractResponseImpl.java
index 2e8ee49..ebe2e5c 100644
--- a/sdk/src/org/opends/sdk/responses/AbstractResponseImpl.java
+++ b/sdk/src/org/opends/sdk/responses/AbstractResponseImpl.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2009 Sun Microsystems, Inc.
+ *      Copyright 2010 Sun Microsystems, Inc.
  */
 
 package org.opends.sdk.responses;
@@ -40,7 +40,6 @@
 import com.sun.opends.sdk.util.Validator;
 
 
-
 /**
  * Modifiable response implementation.
  *
@@ -64,6 +63,23 @@
 
 
   /**
+   * Creates a new abstract response that is an exact copy of the provided
+   * response.
+   *
+   * @param response
+   *          The response to be copied.
+   * @throws NullPointerException
+   *           If {@code response} was {@code null} .
+   */
+  AbstractResponseImpl(Response response) throws NullPointerException
+  {
+    Validator.ensureNotNull(response);
+    controls.addAll(response.getControls());
+  }
+
+
+
+  /**
    * {@inheritDoc}
    */
   public final S addControl(final Control control) throws NullPointerException
diff --git a/sdk/src/org/opends/sdk/responses/AbstractResultImpl.java b/sdk/src/org/opends/sdk/responses/AbstractResultImpl.java
index 8cdc53a..626efb7 100644
--- a/sdk/src/org/opends/sdk/responses/AbstractResultImpl.java
+++ b/sdk/src/org/opends/sdk/responses/AbstractResultImpl.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2009 Sun Microsystems, Inc.
+ *      Copyright 2010 Sun Microsystems, Inc.
  */
 
 package org.opends.sdk.responses;
@@ -77,6 +77,27 @@
 
 
   /**
+   * Creates a new modifiable result that is an exact copy of the provided
+   * result.
+   *
+   * @param result
+   *          The result to be copied.
+   * @throws NullPointerException
+   *           If {@code result} was {@code null}.
+   */
+  AbstractResultImpl(Result result) throws NullPointerException
+  {
+    super(result);
+    this.cause = result.getCause();
+    this.diagnosticMessage = result.getDiagnosticMessage();
+    this.matchedDN = result.getMatchedDN();
+    this.referralURIs.addAll(result.getReferralURIs());
+    this.resultCode = result.getResultCode();
+  }
+
+
+
+  /**
    * {@inheritDoc}
    */
   public final S addReferralURI(final String uri) throws NullPointerException
diff --git a/sdk/src/org/opends/sdk/responses/AbstractUnmodifiableExtendedResultImpl.java b/sdk/src/org/opends/sdk/responses/AbstractUnmodifiableExtendedResultImpl.java
new file mode 100644
index 0000000..8c796e6
--- /dev/null
+++ b/sdk/src/org/opends/sdk/responses/AbstractUnmodifiableExtendedResultImpl.java
@@ -0,0 +1,60 @@
+/*
+ * 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 2010 Sun Microsystems, Inc.
+ */
+
+package org.opends.sdk.responses;
+
+import org.opends.sdk.ByteString;
+
+/**
+ * An abstract unmodifiable Extended result which can be used as the basis for
+ * implementing new unmodifiable Extended operations.
+ *
+ * @param <S>
+ *          The type of Extended result.
+ */
+abstract class AbstractUnmodifiableExtendedResultImpl<S extends ExtendedResult>
+    extends AbstractUnmodifiableResultImpl<S> implements ExtendedResult
+{
+  protected AbstractUnmodifiableExtendedResultImpl(S impl) {
+    super(impl);
+  }
+
+  @Override
+  public String getOID() {
+    return impl.getOID();
+  }
+
+  @Override
+  public ByteString getValue() {
+    return impl.getValue();
+  }
+
+  @Override
+  public boolean hasValue() {
+    return impl.hasValue();
+  }
+}
diff --git a/sdk/src/org/opends/sdk/responses/AbstractUnmodifiableIntermediateResponseImpl.java b/sdk/src/org/opends/sdk/responses/AbstractUnmodifiableIntermediateResponseImpl.java
new file mode 100644
index 0000000..dbd05c6
--- /dev/null
+++ b/sdk/src/org/opends/sdk/responses/AbstractUnmodifiableIntermediateResponseImpl.java
@@ -0,0 +1,61 @@
+/*
+ * 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 2010 Sun Microsystems, Inc.
+ */
+
+package org.opends.sdk.responses;
+
+import org.opends.sdk.ByteString;
+
+/**
+ * An abstract unmodifiable Intermediate response which can be used as the basis
+ * for implementing new unmodifiable Intermediate responses.
+ *
+ * @param <S>
+ *          The type of Intermediate response.
+ */
+abstract class AbstractUnmodifiableIntermediateResponseImpl
+    <S extends IntermediateResponse> extends AbstractUnmodifiableResponseImpl<S>
+    implements IntermediateResponse
+{
+  protected AbstractUnmodifiableIntermediateResponseImpl(S impl) {
+    super(impl);
+  }
+
+  @Override
+  public String getOID() {
+    return impl.getOID();
+  }
+
+  @Override
+  public ByteString getValue() {
+    return impl.getValue();
+  }
+
+  @Override
+  public boolean hasValue() {
+    return impl.hasValue();
+  }
+}
diff --git a/sdk/src/org/opends/sdk/responses/AbstractUnmodifiableResponseImpl.java b/sdk/src/org/opends/sdk/responses/AbstractUnmodifiableResponseImpl.java
index f2f0abd..7d813b3 100644
--- a/sdk/src/org/opends/sdk/responses/AbstractUnmodifiableResponseImpl.java
+++ b/sdk/src/org/opends/sdk/responses/AbstractUnmodifiableResponseImpl.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2009 Sun Microsystems, Inc.
+ *      Copyright 2010 Sun Microsystems, Inc.
  */
 
 package org.opends.sdk.responses;
@@ -32,6 +32,7 @@
 import java.util.Collections;
 import java.util.List;
 
+import com.sun.opends.sdk.util.Validator;
 import org.opends.sdk.DecodeException;
 import org.opends.sdk.DecodeOptions;
 import org.opends.sdk.controls.Control;
@@ -49,7 +50,7 @@
     Response
 {
 
-  private final S impl;
+  protected final S impl;
 
 
 
@@ -61,6 +62,7 @@
    */
   AbstractUnmodifiableResponseImpl(final S impl)
   {
+    Validator.ensureNotNull(impl);
     this.impl = impl;
   }
 
diff --git a/sdk/src/org/opends/sdk/responses/AbstractUnmodifiableResultImpl.java b/sdk/src/org/opends/sdk/responses/AbstractUnmodifiableResultImpl.java
index fa64f00..827d90f 100644
--- a/sdk/src/org/opends/sdk/responses/AbstractUnmodifiableResultImpl.java
+++ b/sdk/src/org/opends/sdk/responses/AbstractUnmodifiableResultImpl.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2009 Sun Microsystems, Inc.
+ *      Copyright 2010 Sun Microsystems, Inc.
  */
 
 package org.opends.sdk.responses;
@@ -46,10 +46,6 @@
     AbstractUnmodifiableResponseImpl<S> implements Result
 {
 
-  private final S impl;
-
-
-
   /**
    * Creates a new unmodifiable result implementation.
    *
@@ -59,7 +55,6 @@
   AbstractUnmodifiableResultImpl(final S impl)
   {
     super(impl);
-    this.impl = impl;
   }
 
 
diff --git a/sdk/src/org/opends/sdk/responses/BindResultImpl.java b/sdk/src/org/opends/sdk/responses/BindResultImpl.java
index 3a1fa84..a10bc39 100644
--- a/sdk/src/org/opends/sdk/responses/BindResultImpl.java
+++ b/sdk/src/org/opends/sdk/responses/BindResultImpl.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2009 Sun Microsystems, Inc.
+ *      Copyright 2010 Sun Microsystems, Inc.
  */
 
 package org.opends.sdk.responses;
@@ -60,6 +60,24 @@
 
 
   /**
+   * Creates a new bind result that is an exact copy of the provided
+   * result.
+   *
+   * @param bindResult
+   *          The bind result to be copied.
+   * @throws NullPointerException
+   *           If {@code bindResult} was {@code null} .
+   */
+  BindResultImpl(final BindResult bindResult)
+      throws NullPointerException
+  {
+    super(bindResult);
+    this.credentials = bindResult.getServerSASLCredentials();
+  }
+
+
+
+  /**
    * {@inheritDoc}
    */
   public ByteString getServerSASLCredentials()
diff --git a/sdk/src/org/opends/sdk/responses/CompareResultImpl.java b/sdk/src/org/opends/sdk/responses/CompareResultImpl.java
index ef4331f..01dcf0c 100644
--- a/sdk/src/org/opends/sdk/responses/CompareResultImpl.java
+++ b/sdk/src/org/opends/sdk/responses/CompareResultImpl.java
@@ -56,6 +56,23 @@
 
 
   /**
+   * Creates a new compare result that is an exact copy of the provided
+   * result.
+   *
+   * @param compareResult
+   *          The compare result to be copied.
+   * @throws NullPointerException
+   *           If {@code compareResult} was {@code null} .
+   */
+  CompareResultImpl(final CompareResult compareResult)
+      throws NullPointerException
+  {
+    super(compareResult);
+  }
+
+
+
+  /**
    * {@inheritDoc}
    */
   public boolean matched()
diff --git a/sdk/src/org/opends/sdk/responses/GenericExtendedResultImpl.java b/sdk/src/org/opends/sdk/responses/GenericExtendedResultImpl.java
index 96de633..d747f32 100644
--- a/sdk/src/org/opends/sdk/responses/GenericExtendedResultImpl.java
+++ b/sdk/src/org/opends/sdk/responses/GenericExtendedResultImpl.java
@@ -40,7 +40,7 @@
  * Generic extended result implementation.
  */
 final class GenericExtendedResultImpl extends
-    AbstractResultImpl<GenericExtendedResult> implements ExtendedResult,
+    AbstractExtendedResultImpl<GenericExtendedResult> implements ExtendedResult,
     GenericExtendedResult
 {
 
@@ -67,6 +67,25 @@
 
 
   /**
+   * Creates a new generic extended result that is an exact copy of the provided
+   * result.
+   *
+   * @param genericExtendedResult
+   *          The generic extended result to be copied.
+   * @throws NullPointerException
+   *           If {@code genericExtendedResult} was {@code null} .
+   */
+  GenericExtendedResultImpl(final GenericExtendedResult genericExtendedResult)
+      throws NullPointerException
+  {
+    super(genericExtendedResult);
+    this.responseName = genericExtendedResult.getOID();
+    this.responseValue = genericExtendedResult.getValue();
+  }
+
+
+
+  /**
    * {@inheritDoc}
    */
   public String getOID()
@@ -147,12 +166,4 @@
     builder.append(")");
     return builder.toString();
   }
-
-
-
-  @Override
-  GenericExtendedResult getThis()
-  {
-    return this;
-  }
 }
diff --git a/sdk/src/org/opends/sdk/responses/GenericIntermediateResponseImpl.java b/sdk/src/org/opends/sdk/responses/GenericIntermediateResponseImpl.java
index 7cc9838..aa5d20b 100644
--- a/sdk/src/org/opends/sdk/responses/GenericIntermediateResponseImpl.java
+++ b/sdk/src/org/opends/sdk/responses/GenericIntermediateResponseImpl.java
@@ -39,7 +39,7 @@
  * Generic intermediate response implementation.
  */
 final class GenericIntermediateResponseImpl extends
-    AbstractIntermediateResponse<GenericIntermediateResponse> implements
+    AbstractIntermediateResponseImpl<GenericIntermediateResponse> implements
     GenericIntermediateResponse
 {
 
@@ -72,6 +72,26 @@
 
 
   /**
+   * Creates a new generic intermediate response that is an exact copy of the
+   * provided result.
+   *
+   * @param genericIntermediateResponse
+   *          The generic intermediate response to be copied.
+   * @throws NullPointerException
+   *           If {@code genericExtendedResult} was {@code null} .
+   */
+  GenericIntermediateResponseImpl(
+      final GenericIntermediateResponse genericIntermediateResponse)
+      throws NullPointerException
+  {
+    super(genericIntermediateResponse);
+    this.responseName = genericIntermediateResponse.getOID();
+    this.responseValue = genericIntermediateResponse.getValue();
+  }
+
+
+
+  /**
    * {@inheritDoc}
    */
   @Override
diff --git a/sdk/src/org/opends/sdk/responses/PasswordModifyExtendedResult.java b/sdk/src/org/opends/sdk/responses/PasswordModifyExtendedResult.java
index 4f2911d..3e33f7a 100644
--- a/sdk/src/org/opends/sdk/responses/PasswordModifyExtendedResult.java
+++ b/sdk/src/org/opends/sdk/responses/PasswordModifyExtendedResult.java
@@ -200,8 +200,12 @@
    *          The generated password, or {@code null} if there is no generated
    *          password associated with this result.
    * @return This password modify result.
+   * @throws UnsupportedOperationException
+   *           If this password modify extended result does not permit the
+   *           generated password to be set.
    */
-  PasswordModifyExtendedResult setGeneratedPassword(ByteString password);
+  PasswordModifyExtendedResult setGeneratedPassword(ByteString password)
+      throws UnsupportedOperationException;
 
 
 
@@ -213,8 +217,12 @@
    *          The generated password, or {@code null} if there is no generated
    *          password associated with this result.
    * @return This password modify result.
+   * @throws UnsupportedOperationException
+   *           If this password modify extended result does not permit the
+   *           generated password to be set.
    */
-  PasswordModifyExtendedResult setGeneratedPassword(String password);
+  PasswordModifyExtendedResult setGeneratedPassword(String password)
+      throws UnsupportedOperationException;
 
 
 
diff --git a/sdk/src/org/opends/sdk/responses/PasswordModifyExtendedResultImpl.java b/sdk/src/org/opends/sdk/responses/PasswordModifyExtendedResultImpl.java
index 5a1e4a2..f7069cf 100644
--- a/sdk/src/org/opends/sdk/responses/PasswordModifyExtendedResultImpl.java
+++ b/sdk/src/org/opends/sdk/responses/PasswordModifyExtendedResultImpl.java
@@ -43,7 +43,7 @@
  * Password modify extended result implementation.
  */
 final class PasswordModifyExtendedResultImpl extends
-    AbstractExtendedResult<PasswordModifyExtendedResult> implements
+    AbstractExtendedResultImpl<PasswordModifyExtendedResult> implements
     PasswordModifyExtendedResult
 {
   private ByteString password;
@@ -52,7 +52,8 @@
    * The ASN.1 element type that will be used to encode the genPasswd component
    * in a password modify extended response.
    */
-  private static final byte TYPE_PASSWORD_MODIFY_GENERATED_PASSWORD = (byte) 0x80;
+  private static final byte TYPE_PASSWORD_MODIFY_GENERATED_PASSWORD =
+      (byte) 0x80;
 
 
 
@@ -65,6 +66,25 @@
 
 
   /**
+   * Creates a new password modify extended result that is an exact copy of the
+   * provided result.
+   *
+   * @param passwordModifyExtendedResult
+   *          The password modify extended result to be copied.
+   * @throws NullPointerException
+   *           If {@code passwordModifyExtendedResult} was {@code null} .
+   */
+  PasswordModifyExtendedResultImpl(
+      final PasswordModifyExtendedResult passwordModifyExtendedResult)
+      throws NullPointerException
+  {
+    super(passwordModifyExtendedResult);
+    this.password = passwordModifyExtendedResult.getGeneratedPassword();
+  }
+
+
+
+  /**
    * {@inheritDoc}
    */
   public ByteString getGeneratedPassword()
@@ -142,7 +162,7 @@
    * {@inheritDoc}
    */
   public PasswordModifyExtendedResult setGeneratedPassword(
-      final ByteString password)
+      final ByteString password) throws UnsupportedOperationException
   {
     this.password = password;
     return this;
@@ -153,7 +173,8 @@
   /**
    * {@inheritDoc}
    */
-  public PasswordModifyExtendedResult setGeneratedPassword(final String password)
+  public PasswordModifyExtendedResult setGeneratedPassword(
+      final String password) throws UnsupportedOperationException
   {
     this.password = (password != null) ? ByteString.valueOf(password) : null;
     return this;
diff --git a/sdk/src/org/opends/sdk/responses/Responses.java b/sdk/src/org/opends/sdk/responses/Responses.java
index af646d3..bf4a15b 100644
--- a/sdk/src/org/opends/sdk/responses/Responses.java
+++ b/sdk/src/org/opends/sdk/responses/Responses.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2009 Sun Microsystems, Inc.
+ *      Copyright 2010 Sun Microsystems, Inc.
  */
 
 package org.opends.sdk.responses;
@@ -42,8 +42,6 @@
  * <p>
  * TODO: referral from LDAP URL.
  * <p>
- * TODO: unmodifiable requests?
- * <p>
  * TODO: synchronized requests?
  * <p>
  * TODO: copy constructors.
@@ -290,7 +288,7 @@
    * @throws NullPointerException
    *           If {@code resultCode} was {@code null} .
    */
-  public static final WhoAmIExtendedResult newWhoAmIExtendedResult(
+  public static WhoAmIExtendedResult newWhoAmIExtendedResult(
       final ResultCode resultCode) throws NullPointerException
   {
     Validator.ensureNotNull(resultCode);
@@ -299,6 +297,344 @@
 
 
 
+  /**
+   * Creates an unmodifiable bind result using the provided response.
+   *
+   * @param bindResult
+   *          The bind result to be copied.
+   * @return The unmodifiable bind result.
+   * @throws NullPointerException
+   *           If {@code bindResult} was {@code null}.
+   */
+  public static BindResult unmodifiableBindResult(final BindResult bindResult)
+      throws NullPointerException
+  {
+    return new UnmodifiableBindResultImpl(bindResult);
+  }
+
+
+
+  /**
+   * Creates an unmodifiable compare result using the provided response.
+   *
+   * @param compareResult
+   *          The compare result to be copied.
+   * @return The unmodifiable compare result.
+   * @throws NullPointerException
+   *           If {@code compareResult} was {@code null}.
+   */
+  public static CompareResult unmodifiableCompareResult(
+      final CompareResult compareResult)
+      throws NullPointerException
+  {
+    return new UnmodifiableCompareResultImpl(compareResult);
+  }
+
+
+
+  /**
+   * Creates an unmodifiable generic extended result using the provided
+   * response.
+   *
+   * @param genericExtendedResult
+   *          The generic extended result to be copied.
+   * @return The unmodifiable generic extended result.
+   * @throws NullPointerException
+   *           If {@code genericExtendedResult} was {@code null}.
+   */
+  public static GenericExtendedResult unmodifiableGenericExtendedResult(
+      final GenericExtendedResult genericExtendedResult)
+      throws NullPointerException
+  {
+    return new UnmodifiableGenericExtendedResultImpl(genericExtendedResult);
+  }
+
+
+
+  /**
+   * Creates an unmodifiable generic intermediate response using the provided
+   * response.
+   *
+   * @param genericIntermediateResponse
+   *          The generic intermediate response to be copied.
+   * @return The unmodifiable generic intermediate response.
+   * @throws NullPointerException
+   *           If {@code genericIntermediateResponse} was {@code null}.
+   */
+  public static GenericIntermediateResponse
+  unmodifiableGenericIntermediateResponse(
+      final GenericIntermediateResponse genericIntermediateResponse)
+      throws NullPointerException
+  {
+    return new UnmodifiableGenericIntermediateResponseImpl(
+        genericIntermediateResponse);
+  }
+
+
+
+  /**
+   * Creates an unmodifiable password modify extended result using the provided
+   * response.
+   *
+   * @param passwordModifyExtendedResult
+   *          The password modify extended result to be copied.
+   * @return The unmodifiable password modify extended result.
+   * @throws NullPointerException
+   *           If {@code passwordModifyExtendedResult} was {@code null}.
+   */
+  public static PasswordModifyExtendedResult
+  unmodifiablePasswordModifyExtendedResult(
+      final PasswordModifyExtendedResult passwordModifyExtendedResult)
+      throws NullPointerException
+  {
+    return new UnmodifiablePasswordModifyExtendedResultImpl(
+        passwordModifyExtendedResult);
+  }
+
+
+
+  /**
+   * Creates an unmodifiable result using the provided response.
+   *
+   * @param result
+   *          The result to be copied.
+   * @return The unmodifiable result.
+   * @throws NullPointerException
+   *           If {@code result} was {@code null}.
+   */
+  public static Result unmodifiableResult(final Result result)
+      throws NullPointerException
+  {
+    return new UnmodifiableResultImpl(result);
+  }
+
+
+
+  /**
+   * Creates an unmodifiable search result entry using the provided response.
+   *
+   * @param searchResultEntry
+   *          The search result entry to be copied.
+   * @return The unmodifiable search result entry.
+   * @throws NullPointerException
+   *           If {@code searchResultEntry} was {@code null}.
+   */
+  public static SearchResultEntry unmodifiableSearchResultEntry(
+      final SearchResultEntry searchResultEntry)
+      throws NullPointerException
+  {
+    return new UnmodifiableSearchResultEntryImpl(searchResultEntry);
+  }
+
+
+
+  /**
+   * Creates an unmodifiable search result reference using the provided
+   * response.
+   *
+   * @param searchResultReference
+   *          The search result reference to be copied.
+   * @return The unmodifiable search result reference.
+   * @throws NullPointerException
+   *           If {@code searchResultReference} was {@code null}.
+   */
+  public static SearchResultReference unmodifiableSearchResultReference(
+      final SearchResultReference searchResultReference)
+      throws NullPointerException
+  {
+    return new UnmodifiableSearchResultReferenceImpl(searchResultReference);
+  }
+
+
+
+  /**
+   * Creates an unmodifiable who am I extended result using the provided
+   * response.
+   *
+   * @param whoAmIExtendedResult
+   *          The who am I result to be copied.
+   * @return The unmodifiable who am I extended result.
+   * @throws NullPointerException
+   *           If {@code whoAmIExtendedResult} was {@code null} .
+   */
+  public static WhoAmIExtendedResult unmodifiableWhoAmIExtendedResult(
+      final WhoAmIExtendedResult whoAmIExtendedResult)
+      throws NullPointerException
+  {
+    return new UnmodifiableWhoAmIExtendedResultImpl(whoAmIExtendedResult);
+  }
+
+
+
+  /**
+   * Creates a new bind result that is an exact copy of the provided
+   * result.
+   *
+   * @param bindResult
+   *          The bind result to be copied.
+   * @return The new bind result.
+   * @throws NullPointerException
+   *           If {@code bindResult} was {@code null}.
+   */
+  public static BindResult copyOfBindResult(final BindResult bindResult)
+      throws NullPointerException
+  {
+    return new BindResultImpl(bindResult);
+  }
+
+
+  /**
+   * Creates a new compare result that is an exact copy of the provided
+   * result.
+   *
+   * @param compareResult
+   *          The compare result to be copied.
+   * @return The new compare result.
+   * @throws NullPointerException
+   *           If {@code compareResult} was {@code null}.
+   */
+  public static CompareResult copyOfCompareResult(
+      final CompareResult compareResult)
+      throws NullPointerException
+  {
+    return new CompareResultImpl(compareResult);
+  }
+
+
+
+  /**
+   * Creates a new generic extended result that is an exact copy of the provided
+   * result.
+   *
+   * @param genericExtendedResult
+   *          The generic extended result to be copied.
+   * @return The new generic extended result.
+   * @throws NullPointerException
+   *           If {@code genericExtendedResult} was {@code null}.
+   */
+  public static GenericExtendedResult copyOfGenericExtendedResult(
+      final GenericExtendedResult genericExtendedResult)
+      throws NullPointerException
+  {
+    return new GenericExtendedResultImpl(genericExtendedResult);
+  }
+
+
+
+  /**
+   * Creates a new generic intermediate response that is an exact copy of the
+   * provided response.
+   *
+   * @param genericIntermediateResponse
+   *          The generic intermediate response to be copied.
+   * @return The new generic intermediate response.
+   * @throws NullPointerException
+   *           If {@code genericIntermediateResponse} was {@code null}.
+   */
+  public static GenericIntermediateResponse copyOfGenericIntermediateResponse(
+      final GenericIntermediateResponse genericIntermediateResponse)
+      throws NullPointerException
+  {
+    return new GenericIntermediateResponseImpl(
+        genericIntermediateResponse);
+  }
+
+
+
+  /**
+   * Creates a new password modify extended result that is an exact copy of the
+   * provided result.
+   *
+   * @param passwordModifyExtendedResult
+   *          The password modify extended result to be copied.
+   * @return The new password modify extended result.
+   * @throws NullPointerException
+   *           If {@code passwordModifyExtendedResult} was {@code null}.
+   */
+  public static PasswordModifyExtendedResult copyOfPasswordModifyExtendedResult(
+      final PasswordModifyExtendedResult passwordModifyExtendedResult)
+      throws NullPointerException
+  {
+    return new PasswordModifyExtendedResultImpl(
+        passwordModifyExtendedResult);
+  }
+
+
+
+  /**
+   * Creates a new result that is an exact copy of the provided result.
+   *
+   * @param result
+   *          The result to be copied.
+   * @return The new result.
+   * @throws NullPointerException
+   *           If {@code result} was {@code null}.
+   */
+  public static Result copyOfResult(final Result result)
+      throws NullPointerException
+  {
+    return new ResultImpl(result);
+  }
+
+
+
+  /**
+   * Creates a new search result entry that is an exact copy of the provided
+   * result.
+   *
+   * @param searchResultEntry
+   *          The search result entry to be copied.
+   * @return The new search result entry.
+   * @throws NullPointerException
+   *           If {@code searchResultEntry} was {@code null}.
+   */
+  public static SearchResultEntry copyOfSearchResultEntry(
+      final SearchResultEntry searchResultEntry)
+      throws NullPointerException
+  {
+    return new SearchResultEntryImpl(searchResultEntry);
+  }
+
+
+
+  /**
+   * Creates a new search result reference that is an exact copy of the provided
+   * result.
+   *
+   * @param searchResultReference
+   *          The search result reference to be copied.
+   * @return The new search result reference.
+   * @throws NullPointerException
+   *           If {@code searchResultReference} was {@code null}.
+   */
+  public static SearchResultReference copyOfSearchResultReference(
+      final SearchResultReference searchResultReference)
+      throws NullPointerException
+  {
+    return new SearchResultReferenceImpl(searchResultReference);
+  }
+
+
+
+  /**
+   * Creates a new who am I extended result that is an exact copy of the
+   * provided result.
+   *
+   * @param whoAmIExtendedResult
+   *          The who am I result to be copied.
+   * @return The new who am I extended result.
+   * @throws NullPointerException
+   *           If {@code whoAmIExtendedResult} was {@code null} .
+   */
+  public static WhoAmIExtendedResult copyOfWhoAmIExtendedResult(
+      final WhoAmIExtendedResult whoAmIExtendedResult)
+      throws NullPointerException
+  {
+    return new WhoAmIExtendedResultImpl(whoAmIExtendedResult);
+  }
+
+
+
   // Private constructor.
   private Responses()
   {
diff --git a/sdk/src/org/opends/sdk/responses/ResultImpl.java b/sdk/src/org/opends/sdk/responses/ResultImpl.java
index 0e80959..8ae508a 100644
--- a/sdk/src/org/opends/sdk/responses/ResultImpl.java
+++ b/sdk/src/org/opends/sdk/responses/ResultImpl.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2009 Sun Microsystems, Inc.
+ *      Copyright 2010 Sun Microsystems, Inc.
  */
 
 package org.opends.sdk.responses;
@@ -55,6 +55,21 @@
 
 
   /**
+   * Creates a new result that is an exact copy of the provided result.
+   *
+   * @param result
+   *          The result to be copied.
+   * @throws NullPointerException
+   *           If {@code result} was {@code null} .
+   */
+  ResultImpl(final Result result) throws NullPointerException
+  {
+    super(result);
+  }
+
+
+
+  /**
    * {@inheritDoc}
    */
   @Override
diff --git a/sdk/src/org/opends/sdk/responses/SearchResultEntryImpl.java b/sdk/src/org/opends/sdk/responses/SearchResultEntryImpl.java
index 0b044ab..5aeb20c 100644
--- a/sdk/src/org/opends/sdk/responses/SearchResultEntryImpl.java
+++ b/sdk/src/org/opends/sdk/responses/SearchResultEntryImpl.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2009-2010 Sun Microsystems, Inc.
+ *      Copyright 2010 Sun Microsystems, Inc.
  */
 
 package org.opends.sdk.responses;
@@ -58,7 +58,7 @@
    * @throws NullPointerException
    *           If {@code entry} was {@code null} .
    */
-  public SearchResultEntryImpl(final Entry entry) throws NullPointerException
+  SearchResultEntryImpl(final Entry entry) throws NullPointerException
   {
     this.entry = entry;
   }
@@ -66,6 +66,24 @@
 
 
   /**
+   * Creates a new search result entry that is an exact copy of the provided
+   * result.
+   *
+   * @param searchResultEntry
+   *          The search result entry to be copied.
+   * @throws NullPointerException
+   *           If {@code searchResultEntry} was {@code null} .
+   */
+  SearchResultEntryImpl(final SearchResultEntry searchResultEntry)
+      throws NullPointerException
+  {
+    super(searchResultEntry);
+    this.entry = new LinkedHashMapEntry(searchResultEntry);
+  }
+
+
+
+  /**
    * {@inheritDoc}
    */
   public boolean addAttribute(final Attribute attribute)
diff --git a/sdk/src/org/opends/sdk/responses/SearchResultReferenceImpl.java b/sdk/src/org/opends/sdk/responses/SearchResultReferenceImpl.java
index abb900e..9f9c102 100644
--- a/sdk/src/org/opends/sdk/responses/SearchResultReferenceImpl.java
+++ b/sdk/src/org/opends/sdk/responses/SearchResultReferenceImpl.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2009 Sun Microsystems, Inc.
+ *      Copyright 2010 Sun Microsystems, Inc.
  */
 
 package org.opends.sdk.responses;
@@ -66,6 +66,24 @@
 
 
   /**
+   * Creates a new search result reference that is an exact copy of the provided
+   * result.
+   *
+   * @param searchResultReference
+   *          The search result reference to be copied.
+   * @throws NullPointerException
+   *           If {@code searchResultReference} was {@code null} .
+   */
+  SearchResultReferenceImpl(final SearchResultReference searchResultReference)
+      throws NullPointerException
+  {
+    super(searchResultReference);
+    this.uris.addAll(searchResultReference.getURIs());
+  }
+
+
+
+  /**
    * {@inheritDoc}
    */
   public SearchResultReference addURI(final String uri)
diff --git a/sdk/src/org/opends/sdk/responses/UnmodifiableBindResultImpl.java b/sdk/src/org/opends/sdk/responses/UnmodifiableBindResultImpl.java
new file mode 100644
index 0000000..7b61774
--- /dev/null
+++ b/sdk/src/org/opends/sdk/responses/UnmodifiableBindResultImpl.java
@@ -0,0 +1,57 @@
+/*
+ * 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 2010 Sun Microsystems, Inc.
+ */
+
+package org.opends.sdk.responses;
+
+import org.opends.sdk.ByteString;
+
+/**
+ * Unmodifiable Bind result implementation.
+ */
+class UnmodifiableBindResultImpl
+    extends AbstractUnmodifiableResultImpl<BindResult> implements BindResult
+{
+  public UnmodifiableBindResultImpl(BindResult impl) {
+    super(impl);
+  }
+
+  @Override
+  public ByteString getServerSASLCredentials() {
+    return impl.getServerSASLCredentials();
+  }
+
+  @Override
+  public boolean isSASLBindInProgress() {
+    return impl.isSASLBindInProgress();
+  }
+
+  @Override
+  public BindResult setServerSASLCredentials(ByteString credentials)
+      throws UnsupportedOperationException {
+    throw new UnsupportedOperationException();
+  }
+}
diff --git a/sdk/src/org/opends/sdk/responses/UnmodifiableCompareResultImpl.java b/sdk/src/org/opends/sdk/responses/UnmodifiableCompareResultImpl.java
new file mode 100644
index 0000000..c2070c5
--- /dev/null
+++ b/sdk/src/org/opends/sdk/responses/UnmodifiableCompareResultImpl.java
@@ -0,0 +1,45 @@
+/*
+ * 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 2010 Sun Microsystems, Inc.
+ */
+
+package org.opends.sdk.responses;
+
+/**
+ * Unmodifiable Compare result implementation.
+ */
+class UnmodifiableCompareResultImpl
+    extends AbstractUnmodifiableResultImpl<CompareResult>
+    implements CompareResult
+{
+  UnmodifiableCompareResultImpl(CompareResult impl) {
+    super(impl);
+  }
+
+  @Override
+  public boolean matched() {
+    return impl.matched();
+  }
+}
diff --git a/sdk/src/org/opends/sdk/responses/UnmodifiableGenericExtendedResultImpl.java b/sdk/src/org/opends/sdk/responses/UnmodifiableGenericExtendedResultImpl.java
new file mode 100644
index 0000000..8d03c17
--- /dev/null
+++ b/sdk/src/org/opends/sdk/responses/UnmodifiableGenericExtendedResultImpl.java
@@ -0,0 +1,54 @@
+/*
+ * 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 2010 Sun Microsystems, Inc.
+ */
+
+package org.opends.sdk.responses;
+
+import org.opends.sdk.ByteString;
+
+/**
+ * Unmodifiable Generic extended result implementation.
+ */
+class UnmodifiableGenericExtendedResultImpl extends
+    AbstractUnmodifiableExtendedResultImpl<GenericExtendedResult>
+    implements ExtendedResult, GenericExtendedResult
+{
+  UnmodifiableGenericExtendedResultImpl(GenericExtendedResult impl) {
+    super(impl);
+  }
+
+  @Override
+  public GenericExtendedResult setOID(String oid)
+      throws UnsupportedOperationException {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public GenericExtendedResult setValue(ByteString bytes)
+      throws UnsupportedOperationException {
+    throw new UnsupportedOperationException();
+  }
+}
diff --git a/sdk/src/org/opends/sdk/responses/UnmodifiableGenericIntermediateResponseImpl.java b/sdk/src/org/opends/sdk/responses/UnmodifiableGenericIntermediateResponseImpl.java
new file mode 100644
index 0000000..f4faa13
--- /dev/null
+++ b/sdk/src/org/opends/sdk/responses/UnmodifiableGenericIntermediateResponseImpl.java
@@ -0,0 +1,55 @@
+/*
+ * 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 2010 Sun Microsystems, Inc.
+ */
+
+package org.opends.sdk.responses;
+
+import org.opends.sdk.ByteString;
+
+/**
+ * Unmodifiable Generic extended result implementation.
+ */
+class UnmodifiableGenericIntermediateResponseImpl extends
+    AbstractUnmodifiableIntermediateResponseImpl<GenericIntermediateResponse>
+    implements GenericIntermediateResponse
+{
+  UnmodifiableGenericIntermediateResponseImpl(
+      GenericIntermediateResponse impl) {
+    super(impl);
+  }
+
+  @Override
+  public GenericIntermediateResponse setOID(String oid)
+      throws UnsupportedOperationException {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public GenericIntermediateResponse setValue(ByteString bytes)
+      throws UnsupportedOperationException {
+    throw new UnsupportedOperationException();
+  }
+}
diff --git a/sdk/src/org/opends/sdk/responses/UnmodifiablePasswordModifyExtendedResultImpl.java b/sdk/src/org/opends/sdk/responses/UnmodifiablePasswordModifyExtendedResultImpl.java
new file mode 100644
index 0000000..4d0e675
--- /dev/null
+++ b/sdk/src/org/opends/sdk/responses/UnmodifiablePasswordModifyExtendedResultImpl.java
@@ -0,0 +1,66 @@
+/*
+ * 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 2010 Sun Microsystems, Inc.
+ */
+
+package org.opends.sdk.responses;
+
+import org.opends.sdk.ByteString;
+
+/**
+ * Unmodifiable Password modify extended result implementation.
+ */
+class UnmodifiablePasswordModifyExtendedResultImpl extends
+    AbstractUnmodifiableExtendedResultImpl<PasswordModifyExtendedResult>
+    implements PasswordModifyExtendedResult
+{
+  UnmodifiablePasswordModifyExtendedResultImpl(
+      PasswordModifyExtendedResult impl) {
+    super(impl);
+  }
+
+  @Override
+  public ByteString getGeneratedPassword() {
+    return impl.getGeneratedPassword();
+  }
+
+  @Override
+  public String getGeneratedPasswordAsString() {
+    return impl.getGeneratedPasswordAsString();
+  }
+
+  @Override
+  public PasswordModifyExtendedResult setGeneratedPassword(ByteString password)
+      throws UnsupportedOperationException
+  {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public PasswordModifyExtendedResult setGeneratedPassword(String password)
+      throws UnsupportedOperationException {
+    throw new UnsupportedOperationException();
+  }
+}
diff --git a/sdk/src/org/opends/sdk/responses/UnmodifiableResultImpl.java b/sdk/src/org/opends/sdk/responses/UnmodifiableResultImpl.java
new file mode 100644
index 0000000..0c498dd
--- /dev/null
+++ b/sdk/src/org/opends/sdk/responses/UnmodifiableResultImpl.java
@@ -0,0 +1,39 @@
+/*
+ * 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 2010 Sun Microsystems, Inc.
+ */
+
+package org.opends.sdk.responses;
+
+/**
+ * A unmodifiable generic result indicates the final status of an operation.
+ */
+class UnmodifiableResultImpl
+    extends AbstractUnmodifiableResultImpl<Result> implements Result
+{
+  UnmodifiableResultImpl(Result impl) {
+    super(impl);
+  }
+}
diff --git a/sdk/src/org/opends/sdk/responses/UnmodifiableSearchResultEntryImpl.java b/sdk/src/org/opends/sdk/responses/UnmodifiableSearchResultEntryImpl.java
new file mode 100644
index 0000000..db7dae9
--- /dev/null
+++ b/sdk/src/org/opends/sdk/responses/UnmodifiableSearchResultEntryImpl.java
@@ -0,0 +1,196 @@
+/*
+ * 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 2010 Sun Microsystems, Inc.
+ */
+
+package org.opends.sdk.responses;
+
+import com.sun.opends.sdk.util.Function;
+import com.sun.opends.sdk.util.Iterables;
+import org.opends.sdk.*;
+
+import java.util.Collection;
+
+/**
+ * Unmodifiable Search result entry implementation.
+ */
+class UnmodifiableSearchResultEntryImpl  extends
+    AbstractUnmodifiableResponseImpl<SearchResultEntry>
+    implements SearchResultEntry
+{
+  private static final Function<Attribute, Attribute, Void>
+      UNMODIFIABLE_ATTRIBUTE_FUNCTION =
+      new Function<Attribute, Attribute, Void>()
+      {
+
+        public Attribute apply(final Attribute value, final Void p)
+        {
+          return Attributes.unmodifiableAttribute(value);
+        }
+
+      };
+
+  UnmodifiableSearchResultEntryImpl(SearchResultEntry impl) {
+    super(impl);
+  }
+
+  public boolean addAttribute(Attribute attribute)
+      throws UnsupportedOperationException, NullPointerException {
+    throw new UnsupportedOperationException();
+  }
+
+  public boolean addAttribute(Attribute attribute,
+                              Collection<ByteString> duplicateValues)
+      throws UnsupportedOperationException, NullPointerException {
+    throw new UnsupportedOperationException();
+  }
+
+  public SearchResultEntry addAttribute(String attributeDescription,
+                                        Object... values)
+      throws LocalizedIllegalArgumentException,
+      UnsupportedOperationException, NullPointerException {
+    throw new UnsupportedOperationException();
+  }
+
+  public SearchResultEntry clearAttributes()
+      throws UnsupportedOperationException {
+    throw new UnsupportedOperationException();
+  }
+
+  public boolean containsAttribute(Attribute attribute,
+                                   Collection<ByteString> missingValues)
+      throws NullPointerException {
+    return impl.containsAttribute(attribute, missingValues);
+  }
+
+  public boolean containsAttribute(String attributeDescription,
+                                   Object... values)
+      throws LocalizedIllegalArgumentException,
+      NullPointerException {
+    return impl.containsAttribute(attributeDescription, values);
+  }
+
+  public Iterable<Attribute> getAllAttributes() {
+    return Iterables.unmodifiable(Iterables.transform(impl
+        .getAllAttributes(), UNMODIFIABLE_ATTRIBUTE_FUNCTION));
+  }
+
+  public Iterable<Attribute> getAllAttributes(
+      AttributeDescription attributeDescription)
+      throws NullPointerException {
+    return Iterables.unmodifiable(Iterables.transform(impl
+        .getAllAttributes(attributeDescription),
+        UNMODIFIABLE_ATTRIBUTE_FUNCTION));
+  }
+
+  public Iterable<Attribute> getAllAttributes(
+      String attributeDescription)
+      throws LocalizedIllegalArgumentException,
+      NullPointerException {
+    return Iterables.unmodifiable(Iterables.transform(impl
+        .getAllAttributes(attributeDescription),
+        UNMODIFIABLE_ATTRIBUTE_FUNCTION));
+  }
+
+  public Attribute getAttribute(
+      AttributeDescription attributeDescription)
+      throws NullPointerException {
+    final Attribute attribute =
+        impl.getAttribute(attributeDescription);
+    if (attribute != null)
+    {
+      return Attributes.unmodifiableAttribute(attribute);
+    }
+    else
+    {
+      return null;
+    }
+  }
+
+  public Attribute getAttribute(String attributeDescription)
+      throws LocalizedIllegalArgumentException,
+      NullPointerException {
+    final Attribute attribute =
+        impl.getAttribute(attributeDescription);
+    if (attribute != null)
+    {
+      return Attributes.unmodifiableAttribute(attribute);
+    }
+    else
+    {
+      return null;
+    }
+  }
+
+  public int getAttributeCount() {
+    return impl.getAttributeCount();
+  }
+
+  public DN getName() {
+    return impl.getName();
+  }
+
+  public boolean removeAttribute(Attribute attribute,
+                                 Collection<ByteString> missingValues)
+      throws UnsupportedOperationException, NullPointerException {
+    throw new UnsupportedOperationException();
+  }
+
+  public boolean removeAttribute(
+      AttributeDescription attributeDescription)
+      throws UnsupportedOperationException, NullPointerException {
+    throw new UnsupportedOperationException();
+  }
+
+  public SearchResultEntry removeAttribute(String attributeDescription,
+                                           Object... values)
+      throws LocalizedIllegalArgumentException,
+      UnsupportedOperationException, NullPointerException {
+    throw new UnsupportedOperationException();
+  }
+
+  public boolean replaceAttribute(Attribute attribute)
+      throws UnsupportedOperationException, NullPointerException {
+    throw new UnsupportedOperationException();
+  }
+
+  public SearchResultEntry replaceAttribute(String attributeDescription,
+                                            Object... values)
+      throws LocalizedIllegalArgumentException,
+      UnsupportedOperationException, NullPointerException {
+    throw new UnsupportedOperationException();
+  }
+
+  public SearchResultEntry setName(DN dn)
+      throws UnsupportedOperationException, NullPointerException {
+    throw new UnsupportedOperationException();
+  }
+
+  public SearchResultEntry setName(String dn)
+      throws LocalizedIllegalArgumentException,
+      UnsupportedOperationException, NullPointerException {
+    throw new UnsupportedOperationException();
+  }
+}
diff --git a/sdk/src/org/opends/sdk/responses/UnmodifiableSearchResultReferenceImpl.java b/sdk/src/org/opends/sdk/responses/UnmodifiableSearchResultReferenceImpl.java
new file mode 100644
index 0000000..48b284d
--- /dev/null
+++ b/sdk/src/org/opends/sdk/responses/UnmodifiableSearchResultReferenceImpl.java
@@ -0,0 +1,53 @@
+/*
+ * 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 2010 Sun Microsystems, Inc.
+ */
+
+package org.opends.sdk.responses;
+
+import java.util.List;
+
+/**
+ * Unmodifiable Search result reference implementation.
+ */
+class UnmodifiableSearchResultReferenceImpl extends
+    AbstractUnmodifiableResponseImpl<SearchResultReference> implements
+    SearchResultReference
+{
+  UnmodifiableSearchResultReferenceImpl(SearchResultReference impl) {
+    super(impl);
+  }
+
+  @Override
+  public SearchResultReference addURI(String uri)
+      throws UnsupportedOperationException, NullPointerException {
+    throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public List<String> getURIs() {
+    return impl.getURIs();
+  }
+}
diff --git a/sdk/src/org/opends/sdk/responses/UnmodifiableWhoAmIExtendedResultImpl.java b/sdk/src/org/opends/sdk/responses/UnmodifiableWhoAmIExtendedResultImpl.java
new file mode 100644
index 0000000..5b004d3
--- /dev/null
+++ b/sdk/src/org/opends/sdk/responses/UnmodifiableWhoAmIExtendedResultImpl.java
@@ -0,0 +1,53 @@
+/*
+ * 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 2010 Sun Microsystems, Inc.
+ */
+
+package org.opends.sdk.responses;
+
+import org.opends.sdk.LocalizedIllegalArgumentException;
+
+/**
+ * Unmodifiable Who Am I extended result implementation.
+ */
+class UnmodifiableWhoAmIExtendedResultImpl extends
+    AbstractUnmodifiableExtendedResultImpl<WhoAmIExtendedResult> implements
+    WhoAmIExtendedResult
+{
+  UnmodifiableWhoAmIExtendedResultImpl(WhoAmIExtendedResult impl) {
+    super(impl);
+  }
+
+  @Override
+  public String getAuthorizationID() {
+    return impl.getAuthorizationID();
+  }
+
+  @Override
+  public WhoAmIExtendedResult setAuthorizationID(String authorizationID)
+      throws LocalizedIllegalArgumentException, UnsupportedOperationException {
+    throw new UnsupportedOperationException();
+  }
+}
diff --git a/sdk/src/org/opends/sdk/responses/WhoAmIExtendedResult.java b/sdk/src/org/opends/sdk/responses/WhoAmIExtendedResult.java
index 32ec723..bdce671 100644
--- a/sdk/src/org/opends/sdk/responses/WhoAmIExtendedResult.java
+++ b/sdk/src/org/opends/sdk/responses/WhoAmIExtendedResult.java
@@ -181,9 +181,12 @@
    * @throws LocalizedIllegalArgumentException
    *           If {@code authorizationID} was non-empty and did not contain a
    *           valid authorization ID type.
+   * @throws UnsupportedOperationException
+   *           If this who am I extended result does not permit the
+   *           authorization ID to be set.
    */
   WhoAmIExtendedResult setAuthorizationID(String authorizationID)
-      throws LocalizedIllegalArgumentException;
+      throws LocalizedIllegalArgumentException, UnsupportedOperationException;
 
 
 
diff --git a/sdk/src/org/opends/sdk/responses/WhoAmIExtendedResultImpl.java b/sdk/src/org/opends/sdk/responses/WhoAmIExtendedResultImpl.java
index 869cd78..5f30316 100644
--- a/sdk/src/org/opends/sdk/responses/WhoAmIExtendedResultImpl.java
+++ b/sdk/src/org/opends/sdk/responses/WhoAmIExtendedResultImpl.java
@@ -42,7 +42,7 @@
  * Who Am I extended result implementation.
  */
 final class WhoAmIExtendedResultImpl extends
-    AbstractExtendedResult<WhoAmIExtendedResult> implements
+    AbstractExtendedResultImpl<WhoAmIExtendedResult> implements
     WhoAmIExtendedResult
 {
 
@@ -60,6 +60,24 @@
 
 
   /**
+   * Creates a new who am I extended result that is an exact copy of the
+   * provided result.
+   *
+   * @param whoAmIExtendedResult
+   *          The who am I extended result to be copied.
+   * @throws NullPointerException
+   *           If {@code whoAmIExtendedResult} was {@code null} .
+   */
+  WhoAmIExtendedResultImpl(final WhoAmIExtendedResult whoAmIExtendedResult)
+      throws NullPointerException
+  {
+    super(whoAmIExtendedResult);
+    this.authorizationID = whoAmIExtendedResult.getAuthorizationID();
+  }
+
+
+
+  /**
    * {@inheritDoc}
    */
   public String getAuthorizationID()

--
Gitblit v1.10.0