Element.getMixedContent.add(Element)(etc) add TWICE
jerry.lawson at virtualsummit.com
Thu Nov 16 08:16:25 PST 2000
I agree with you. Using the PartialList has always bothered me somehow,
but until you pointed out these deficiencies, I didn't really know why
it bothered me.
Do you have a proposed solution that you could
present on behalf of the rest of us, for approval by Messrs. Hunter
Michael Skells wrote:
> PartailList ( returned by getMixedContent) is a subclass of LinkedList.
> Many of the methods ( add, addAll, removeAll ... ) perform logic to
> maintain the list ( locally held ( by the super class and in the backing
> store, but the superclass calls back to the child to perform actions
> PartialList.addAll(collection) adds to the backing store and calls
> LinkedList.addAll(Collection) to maintain the list, which calls
> PartialList.addAll(int, Collection) the add the elements at the end,
> which adds to the backing store AGAIN and calls
> LinkedList.addAll(int, Collection) to maintain the list.
> This style of coding in not safe as it would be legitimate for
> LinkedList.addAll(int, Collection) to call add(int, Object) which would
> add it a third time!!!
> As the implementation of LinkedList is not part of its specification
> then inheritance is not a safe mechanism to use for this type of
> behavior, and I would strongly suggest that this gets rewritten to use
> To control your jdom-interest membership:
Jerry Lawson Virtual Summit, Inc.
Virtual Programmer jerry.lawson at virtualsummit.com
More information about the jdom-interest