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/LinkedHashMapEntry.java | 44 ++++++++++++++++++++++++++++++++++++++------
1 files changed, 38 insertions(+), 6 deletions(-)
diff --git a/sdk/src/org/opends/sdk/LinkedHashMapEntry.java b/sdk/src/org/opends/sdk/LinkedHashMapEntry.java
index 9ddd0e9..3dd847e 100644
--- a/sdk/src/org/opends/sdk/LinkedHashMapEntry.java
+++ b/sdk/src/org/opends/sdk/LinkedHashMapEntry.java
@@ -38,10 +38,10 @@
/**
- * An implementation of the {@code Entry} interface which uses a {@code
- * LinkedHashMap} for storing attributes. Attributes are returned in the same
- * order that they were added to the entry. All operations are supported by this
- * implementation.
+ * An implementation of the {@code Entry} interface which uses a
+ * {@code LinkedHashMap} for storing attributes. Attributes are returned in the
+ * same order that they were added to the entry. All operations are supported by
+ * this implementation.
* <p>
* A {@code LinkedHashMapEntry} stores references to attributes which have been
* added using the {@link #addAttribute} methods. Attributes sharing the same
@@ -69,6 +69,34 @@
/**
+ * 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 #LinkedHashMapEntry(Entry)}.
+ *
+ * @param entry
+ * The entry to be copied.
+ * @return A deep copy of {@code entry}.
+ * @throws NullPointerException
+ * If {@code entry} was {@code null}.
+ * @see #LinkedHashMapEntry(Entry)
+ */
+ public static LinkedHashMapEntry deepCopyOfEntry(final Entry entry)
+ throws NullPointerException
+ {
+ LinkedHashMapEntry copy = new LinkedHashMapEntry(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 LinkedHashMapEntry()
@@ -97,19 +125,23 @@
/**
* 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 LinkedHashMapEntry(final Entry entry) throws NullPointerException
{
this(entry.getName());
for (final Attribute attribute : entry.getAllAttributes())
{
- addAttribute(new LinkedAttribute(attribute));
+ addAttribute(attribute);
}
}
--
Gitblit v1.10.0