[jdom-interest] Problem with 'setChildren' on JDOM B8
Jason Hunter
jhunter at acm.org
Mon Dec 9 10:34:08 PST 2002
> 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-
More information about the jdom-interest
mailing list