[jdom-interest] Moving Children

Kevin Baynes kbaynes at seagullsw.com
Thu Jun 14 11:34:23 PDT 2001


Jason-

How do I clone the List?

Do you mean to do this?:

// Assume creation of two Elements usersA and usersB, each with children

Element clone = (Element)usersA.clone();

java.util.List listA = clone.getChildren();
java.util.List listB = usersB.getChildren();

listB.addAll( listA  );


Did I misunderstand?

Thanks!

Kevin



> -----Original Message-----
> From: jdom-interest-admin at jdom.org
> [mailto:jdom-interest-admin at jdom.org]On Behalf Of Jason Hunter
> Sent: Thursday, June 07, 2001 4:33 PM
> To: Kevin Baynes
> Cc: Jdom-Interest
> Subject: Re: [jdom-interest] Moving Children
> 
> 
> Kevin Baynes wrote:
> > 
> > I have two nodes that have children. I would like to take all 
> the children
> > from one node and move them to the other. Is there a way to do this
> > *without* looping through each of the children to move and calling
> > Element.detach() ?
> 
> Get the first list, clone it (a shallow clone), call clear() on the
> list, then call addAll() passing the cloned list.  Behind the scenes
> detach() will be called but you don't have to do it.
> 
> Note this may not work perfectly with the internal PartialList impl,
> which is why we're changing to FilterList.
> 
> > Question: The above code will generate an error because all of 
> the children
> > of groupTwo already have a parent, correct?
> 
> Yep.
> 
> -jh-
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/yourad
dr at yourhost.com



More information about the jdom-interest mailing list