[jdom-interest] Merging jdoms

Simon simonjgauld at yahoo.com
Wed May 9 01:46:39 PDT 2001


Rebuild the javadoc using the build scripts; the
detach method should appear if you have the latest
source

.s

--- Ken Rune Helland <kenh at csc.no> wrote: > At 08:09
AM 5/9/2001 +0100, Heather Boyd wrote:
> 
> 
> >Thanks for your suggestion.
> >
> >I also found that this worked :
> >
> >
> >          Document doc = new Document(new
> Element("NEW"));
> >          Element root = doc.getRootElement();
> >
> >          Document doca =  JDomFromAnOtherSource();
> >          Element a = doc.getRootElement();
> >          root.addContent((Element) a.clone());
> >
> >
> >I couldn't find detach() in the javadoc (jdomb6).
> But I imagine its a better
> >solution because it's designed for this purpose.
> >
> 
> It does someting different.  If you use the
> a.clone() metod
> you create a clone/copy iof the "a" element, if "a"
> is big this
> both takes time and consumes memory. But on the
> pluss side
> the "doca" document is still intakt after the clone.
> 
> a.detach() on the other hand removes "a" from "doca"
> leaving
> "doca" in a invalid state by stealing its root
> element.
> 
> So if you need to keep "doca" in its current state
> use a.clone()
> if you are going to trow away "doca" use a.detach()
> for better
> performace both in space and time.
> 
> 
> KenR
> 
> 
> 
> >Heather Boyd wrote:
> > >
> > > I have three small jdoms (all different) and
> would like to create a new
> >jdom
> > > from them, but keep them intact.
> > > In otherwords the old jdoms are copied exactly,
> and their root Element is
> > > added to the root Element
> > > of the new jdom.
> > >
> > > Is there an easy way to do this, ie, I though
> something like this would
> >work
> > > but it
> > > didn't.
> > >
> > > Document doc = new Document(new Element
> ("NEW"));
> > > Element root = doc.getRootElement();
> > >
> > > Document doca =  JDomFromAnOtherSource()
> > > Element a = doc.getRootElement();
> > > root.addContent(a)
> >
> >Call a.detach() to remove "a" from its document
> before adding it to
> >another document.
> >
> >-jh-
> >_______________________________________________
> >To control your jdom-interest membership:
>
>http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
> 
> _______________________________________________
> To control your jdom-interest membership:
>
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com


____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie



More information about the jdom-interest mailing list