[jdom-interest] Problem with 'setChildren' on JDOM B8

David Kavanagh dak at dotech.com
Tue Dec 10 06:33:09 PST 2002


Collections.copy(List dest, List src);

On 12/10/2002 5:23 AM, duncan.loveday at bt.com wrote:

>Jason,
>
>>Cloning the list should accomplish this.  That's what we'd have to do to
>>
>add such a method, and it seems a waste when it's so easy.
>
>Forgive my ignorance. How would I clone a List ? There's no 'clone()' method
>on that interface and I wouldn't want to make assumptions about the
>underlying implementation would I ?
>
>Also, I'd be concerned about making a deep clone that recursively clones all
>the elements and sub-elements within the List from a point of view of run
>time cost. There ought to be a way of just returning a static list of
>references to the content.
>
>Cheers,
>
>Duncan.
>
>-----Original Message-----
>From: Jason Hunter [mailto:jhunter at acm.org]
>Sent: 09 December 2002 18:34
>To: Loveday,DAH,Duncan,YEE24 R
>Cc: jdom-interest at jdom.org
>Subject: Re: [jdom-interest] Problem with 'setChildren' on JDOM B8
>
>
>>Thanks for this. A couple of observations
>>
>>(1) I get no deprecation warnings for setChildren() on compilation and
>>
>don't
>
>>see it as deprecated at
>>
>http://www.jdom.org/docs/apidocs/org/jdom/Element.html#setChildren(java.util
>
>>.List)
>>
>
>Yes, it was deprecated after b8.  Sorry I didn't notice that.  I'm
>running with latest CVS, and it's deprecated there.
>
>>(3) What you suggest would equate in my case to
>>
>>elem.setContent(elem.getChildren());
>>
>>but this clears both text and element content because of the "live" List
>>returned by getChildren(). When 'setContent()' clears the old content, it
>>also clears the new content it is about to replace it with. It might be
>>
>nice
>
>>to have the option to obtain "non-live" Lists that provide a static
>>
>snapshot
>
>>of the content.
>>
>
>Cloning the list should accomplish this.  That's what we'd have to do to
>add such a method, and it seems a waste when it's so easy.
>
>>(4) I would suggest it might also be nice to have methods to clear
>>
>specific
>
>>types of content. For example
>>
>>    public void removeText()
>>
>
>That might be nice, but it's a slippery slope.  I think using the
>general Filter mechanism is a better solution than specific methods for
>every type of filter.  With filters you could just apply a filter that
>prefers everything but text.
>
>>Hope nobody is offended by any of this.
>>
>
>No way, comments like yours are great.  Hope you're not offended by my
>answers.  :-)
>
>-jh-
>
>
>_______________________________________________
>To control your jdom-interest membership:
>http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20021210/f9b1e218/attachment.htm


More information about the jdom-interest mailing list