[jdom-interest] IllegalAddException in sort.
Ed Hurst-Frost
edward at hurst-frost.net
Tue May 28 06:37:48 PDT 2002
I've just switched my application from b7 to b8 and am getting an
IllegalAddException when calling Collections.sort() on a List returned from
getChildren(String).
As the sort tries to rearrange the contents it calls
ContentList.add(int,Element) which sees that an Element is being added that
already has a parent. It doesn't notice that the new parent is the same as
the current one. Would it be reasonable to add the 'same parent' test to the
add() method? It works for me.
ContentList:
protected void add(int index, Element element) {
if (element.getParent() != null && element.getParent() != parent) {
throw new IllegalAddException(
"The element already has an existing parent \""
+element.getParent().getQualifiedName() + \"");
}
Ed Hurst-Frost
More information about the jdom-interest
mailing list