directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1000631 - /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java
Date Thu, 23 Sep 2010 21:27:47 GMT
Author: elecharny
Date: Thu Sep 23 21:27:46 2010
New Revision: 1000631

URL: http://svn.apache.org/viewvc?rev=1000631&view=rev
Log:
Added a getDn() and a clone() method

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java?rev=1000631&r1=1000630&r2=1000631&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java
Thu Sep 23 21:27:46 2010
@@ -43,7 +43,7 @@ import org.slf4j.LoggerFactory;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class DnNode<N>
+public class DnNode<N> implements Cloneable
 {
     /** The logger for this class */
     private static final Logger LOG = LoggerFactory.getLogger( DnNode.class );
@@ -636,6 +636,27 @@ public class DnNode<N>
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
+    public DnNode<N> clone()
+    {
+        DnNode<N> clonedDnNode = new DnNode<N>();
+
+        clonedDnNode.element = element;
+        clonedDnNode.depth = depth;
+        clonedDnNode.parent = parent;
+        clonedDnNode.rdn = rdn;
+
+        for ( DnNode<N> node : children.values() )
+        {
+            clonedDnNode.children.put( rdn, node.clone() );
+        }
+
+        return clonedDnNode;
+    }
+
+
     private String toString( String tabs )
     {
         if ( rdn == null )
@@ -650,11 +671,11 @@ public class DnNode<N>
 
         if ( isLeaf() )
         {
-            sb.append( "Leaf[" ).append( rdn ).append( "]: " ).append( "'" ).append( element
).append( "'" );
+            sb.append( "Leaf[" ).append( dn ).append( "]: " ).append( "'" ).append( element
).append( "'" );
             return sb.toString();
         }
 
-        sb.append( "Branch[" ).append( rdn ).append( "]: " );
+        sb.append( "Branch[" ).append( dn ).append( "]: " );
 
         if ( element != null )
         {
@@ -696,4 +717,13 @@ public class DnNode<N>
     {
         return toString( "" );
     }
+
+
+    /**
+     * @return the dn
+     */
+    public DN getDn()
+    {
+        return dn;
+    }
 }



Mime
View raw message