[jdom-interest] Element.getMixedContent.addAll(Collection) Element.getMixedContent.add(Element)(etc) add TWICE

Jerry Lawson 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
McLaughlin ?

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
> e.g.
> 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
> delegation
> Comments??
> Mike
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

Jerry Lawson                   Virtual Summit, Inc.
Virtual Programmer   jerry.lawson at virtualsummit.com

More information about the jdom-interest mailing list