From ebf96a30d0122d35e271bad15f1f31a0a9100842 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Sun, 24 Oct 2010 20:47:53 +0000
Subject: [PATCH] Sync commits from OpenDS by matthew_swift
---
sdk/src/org/opends/sdk/TreeMapEntry.java | 35 +++++++++++++++++++++++++++++++++--
1 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/sdk/src/org/opends/sdk/TreeMapEntry.java b/sdk/src/org/opends/sdk/TreeMapEntry.java
index 75b46d3..0cd3550 100644
--- a/sdk/src/org/opends/sdk/TreeMapEntry.java
+++ b/sdk/src/org/opends/sdk/TreeMapEntry.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2009 Sun Microsystems, Inc.
+ * Copyright 2009-2010 Sun Microsystems, Inc.
*/
package org.opends.sdk;
@@ -70,6 +70,33 @@
/**
+ * Creates an entry having the same distinguished name, attributes, and object
+ * classes of the provided entry. This constructor performs a deep copy of
+ * {@code entry} and will copy each attribute as a {@link LinkedAttribute}.
+ * <p>
+ * A shallow copy constructor is provided by {@link #TreeMapEntry(Entry)}.
+ *
+ * @param entry
+ * The entry to be copied.
+ * @return A deep copy of {@code entry}.
+ * @throws NullPointerException
+ * If {@code entry} was {@code null}.
+ * @see #TreeMapEntry(Entry)
+ */
+ public static TreeMapEntry deepCopyOfEntry(final Entry entry)
+ throws NullPointerException
+ {
+ TreeMapEntry copy = new TreeMapEntry(entry.getName());
+ for (final Attribute attribute : entry.getAllAttributes())
+ {
+ copy.addAttribute(new LinkedAttribute(attribute));
+ }
+ return copy;
+ }
+
+
+
+ /**
* Creates an entry with an empty (root) distinguished name and no attributes.
*/
public TreeMapEntry()
@@ -98,12 +125,16 @@
/**
* Creates an entry having the same distinguished name, attributes, and object
- * classes of the provided entry.
+ * classes of the provided entry. This constructor performs a shallow copy of
+ * {@code entry} and will not copy the attributes contained in {@code entry}.
+ * <p>
+ * A deep copy constructor is provided by {@link #deepCopyOfEntry(Entry)}
*
* @param entry
* The entry to be copied.
* @throws NullPointerException
* If {@code entry} was {@code null}.
+ * @see #deepCopyOfEntry(Entry)
*/
public TreeMapEntry(final Entry entry) throws NullPointerException
{
--
Gitblit v1.10.0