[jdom-interest] Moving elements

Bradley S. Huffman hip at a.cs.okstate.edu
Thu May 1 16:14:18 PDT 2003


"Alex Rosen" writes:

> The sort() problem is huge, and this change would fix it. If we don't
> make this change, then the obvious way to sort elements,
> Collections.sort(parent.getContent()), will always fail.

Looking at the code for Collections (JDK 1.4.2), I think it will still
fail even with the change since every set() that's not replacing a
object with itself will most likely reduce the number of unseen objects
from the Iterator by 1 (because of the automagic remove) and eventually
it will run out of object eventhough a.length is still > 0. That's if the
current implementation of Iterator in ContentList doesn't throw a
ConcurrentModificationException first.

But I guess the best thing to do is try it and see what happens :)

Also, none of the JDOM objects implement Comparable. And how would you
implement one anyway? Are Text nodes < or > ProcessingIntruction nodes,
Comments, and Elements? 

Brad



More information about the jdom-interest mailing list