@Test public void testRename() throws Exception { DnNode<Dn> rootNode = new DnNode<Dn>(); Dn dn = new Dn( "dc=directory,dc=apache,dc=org" ); rootNode.add( dn ); Rdn childRdn = new Rdn( "dc=org" ); DnNode<Dn> child = rootNode.getChild( childRdn ); assertNotNull( child ); Rdn newChildRdn = new Rdn( "dc=neworg" ); child.rename( newChildRdn ); assertNull( rootNode.getChild( childRdn ) ); assertEquals( new Dn( "dc=neworg" ), child.getDn() ); DnNode<Dn> child2 = child.getChild( new Rdn( "dc=apache" ) ); assertEquals( new Dn( "dc=apache,dc=neworg" ), child2.getDn() ); assertEquals( new Dn( "dc=directory,dc=apache,dc=neworg" ), child2.getChild( new Rdn( "dc=directory" ) ) .getDn() ); assertNotNull( rootNode.getChild( newChildRdn ) ); }
public synchronized void rename( Rdn newRdn ) throws LdapException { Dn temp = nodeDn.getParent(); temp = temp.add( newRdn ); Rdn oldRdn = nodeRdn; nodeRdn = temp.getRdn(); nodeDn = temp; if ( parent != null ) { parent.children.remove( oldRdn.getNormName() ); parent.children.put( nodeRdn.getNormName(), this ); } updateAfterModDn( nodeDn ); }
DnNode { public synchronized void rename( Rdn newRdn ) throws LdapException { Dn temp = nodeDn.getParent(); temp = temp.add( newRdn ); Rdn oldRdn = nodeRdn; nodeRdn = temp.getRdn(); nodeDn = temp; if ( parent != null ) { parent.children.remove( oldRdn.getNormName() ); parent.children.put( nodeRdn.getNormName(), this ); } updateAfterModDn( nodeDn ); } }
DnNode { public synchronized void rename( Rdn newRdn ) throws LdapException { Dn temp = nodeDn.getParent(); temp = temp.add( newRdn ); Rdn oldRdn = nodeRdn; nodeRdn = temp.getRdn(); nodeDn = temp; if ( parent != null ) { parent.children.remove( oldRdn.getNormName() ); parent.children.put( nodeRdn.getNormName(), this ); } updateAfterModDn( nodeDn ); } DnNode();  DnNode( N element );  DnNode( Dn dn, N element ); }
DnNode { public synchronized void rename( Rdn newRdn ) throws LdapException { Dn temp = nodeDn.getParent(); temp = temp.add( newRdn ); Rdn oldRdn = nodeRdn; nodeRdn = temp.getRdn(); nodeDn = temp; if ( parent != null ) { parent.children.remove( oldRdn.getNormName() ); parent.children.put( nodeRdn.getNormName(), this ); } updateAfterModDn( nodeDn ); } DnNode();  DnNode( N element );  DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn(); }
DnNode { public synchronized void rename( Rdn newRdn ) throws LdapException { Dn temp = nodeDn.getParent(); temp = temp.add( newRdn ); Rdn oldRdn = nodeRdn; nodeRdn = temp.getRdn(); nodeDn = temp; if ( parent != null ) { parent.children.remove( oldRdn.getNormName() ); parent.children.put( nodeRdn.getNormName(), this ); } updateAfterModDn( nodeDn ); } DnNode();  DnNode( N element );  DnNode( Dn dn, N element ); synchronized boolean isLeaf(); synchronized boolean isLeaf( Dn dn ); synchronized int size(); synchronized N getElement(); synchronized N getElement( Dn dn ); synchronized boolean hasElement(); synchronized boolean hasElement( Dn dn ); synchronized boolean hasDescendantElement( Dn dn ); synchronized List<N> getDescendantElements( Dn dn ); synchronized boolean hasChildren(); synchronized boolean hasChildren( Dn dn ); synchronized Map<String, DnNode<N>> getChildren(); synchronized DnNode<N> getParent(); synchronized boolean hasParent(); synchronized boolean hasParent( Dn dn ); synchronized DnNode<N> add( Dn dn ); synchronized DnNode<N> add( Dn dn, N element ); synchronized void remove( Dn dn ); synchronized boolean contains( Rdn rdn ); synchronized DnNode<N> getChild( Rdn rdn ); synchronized Rdn getRdn(); synchronized DnNode<N> getNode( Dn dn ); synchronized boolean hasParentElement( Dn dn ); synchronized DnNode<N> getParentWithElement( Dn dn ); synchronized DnNode<N> getParentWithElement(); synchronized void rename( Rdn newRdn ); synchronized void move( Dn newParent ); @Override String toString(); synchronized Dn getDn();  }