[jdom-interest] Why don't Comment, Element, Text, etc extend common jdom object?

bob mcwhirter bob at werken.com
Mon May 27 17:16:41 PDT 2002


This should be a faq...

If you're using an Iterator to iterate, then use the remove() method of
the iterator to remove the element from the list.  Iterator::remove()
calls detach() behind the scenes.

Answered many times, but I'm not certain if it should be a FAQ, or if
the numerous questions presented show us some possible design flaw.

Can anyone think of a way for either detach() or Iterator::remove() to be
legal?

Seems strange to direct folks -away- from the object-model API, and towards
the Java Collections API.  It seems to obfuscate what's really going on.

	"Yes, I know you want to detach an element, and there's a
	method called 'detach()', but don't use it, in this case."

Hmmm..

Granted, might be difficult to catch.  No simple way to tell if the
detach() is happenining within the iteration loop, or from some other
thread.


	-bob

On Mon, 27 May 2002, J S wrote:

> This would be helpful in the following situation:
> 
> List l = rootTitle.getContent();
> Iterator it = l.iterator();
> 			
> Vector titleChildren = new Vector();
> while(it.hasNext() )  {
>    JdomObject e = (JdomObject) it.next();
>    e.detach();
>    titleChildren.add(e);
> }
> 
> Also calling e.detach seems to throw a concurrent
> modification exception.  Anyone understand why?  To
> get around that I interate through my new list of
> objects afterwards, which works fine.
> 
> Thanks,
> 
> Jo
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
> _______________________________________________
> 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