[jdom-interest] Returning List in Element and Document

Jan Peter Hecking jan at netgaroo.com
Thu Feb 8 02:49:59 PST 2001

On Thu, Feb 08, 2001 at 05:03:37PM +0800, Sng Wee Jim wrote:
> I noticed that the List were returned 'live' (see API docs) in the
> classes Element and Document. Are there any reasonale behind this?

As I understand it this is a feature of JDOM, not a bug. One of the
goals of JDOM is to create an API that is as easy and convenient to
use for the Java programmer as possible. Therefor it is reasonable
to rely on the already existing Java Collections API instead of
trying to duplicate this functionality within the JDOM API.

E.g. the List interface allows you to add (remove) whole
collections of Elements as children to (from) another element. Or
you can use an ListIterator to find and remove children, etc.

This is even the prefered way of handling Element children, as (at
least with the latest beta5) the removeChild( Comment/Element/... )
methods of Element are deprecated.


Jan Peter Hecking                  jhecking at netgaroo.com
University of Rostock     Department of Computer Science
Homepage: http://www.informatik.uni-rostock.de/~jhecking

More information about the jdom-interest mailing list