Fwd: [jdom-interest] elt.getContent().iterator().remove() - a bug?
Jason Hunter
jhunter at collab.net
Wed Oct 3 15:08:41 PDT 2001
The iterator used by PartialList has some bugs, and most likely you're
hitting one of them. PartialList uses an approach to making the list
"live" which is fraught with problems. That's why FilterList is being
written; it's just not live yet.
Your code will work if you do e.removeContent((Comment)o). If you want
to look at fixing the PartialList iterator, that'd be a fine approach
also.
-jh-
>
> --- Noam Tamim <noamt at yahoo.com> wrote:
> > From: Noam Tamim <noamt at yahoo.com>
> > To: jdom-interest at jdom.org
> > Subject: [jdom-interest] elt.getContent().iterator().remove() - a
> > bug?
> > Date: Mon, 1 Oct 2001 11:30:11 -0700 (PDT)
> >
> > Hi.
> >
> > I am trying to build a util that removes comments from XML files.
> > The relevant part is this method:
> >
> > static void removeComments(Element e) {
> > Iterator i=e.getContent().iterator();
> > while (i.hasNext()) {
> > Object o=i.next();
> > if (o instanceof Comment) {
> > System.out.println("removing: "+o);
> > i.remove();
> > }
> > else if (o instanceof Element) removeComments((Element)o);
> > }
> > }
> >
> > I successfully traverses the whole tree from the given Element
> > down
> > (as seen by the "removing" line), yet not a single Comment is
> > removed.
> > Am I doing something wrong, or is that a (known?) bug?
> > I looked at the source of Element, PartialList, and LinkedList,
> > and
> > found no answer.
> > Please help me.
> >
> > -Noam.
>
> =====
> - Noam.
>
> __________________________________________________
> Do You Yahoo!?
> NEW from Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
> http://geocities.yahoo.com/ps/info1
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
More information about the jdom-interest
mailing list