[jdom-interest] Last call: getChild/getChildren versusgetChildElement/getChildElements

Bradley S. Huffman hip at cs.okstate.edu
Mon Feb 9 16:22:54 PST 2004

Jason Hunter writes:

> I've been contemplating the idea of, after shipping JDOM 1.0, following 
> it with a J2SE 1.5 enabled alternate version.  The J2SE 1.5 version 
> would take advantage of generics and "covariant return types".  This way 
> the Lists returned would be Lists of Element or Lists of Content. 
> Covariant return types are even cooler, and let you return a specific 
> subclass of the parent's return type.  So for example getParent() on 
> Text could return an Element even though the inherited getParent() only 
> says it returns a Parent.  There's lots of neat options.
> What do people think?  Perhaps call it Generic JDOM.  :-)  If nothing 
> else, it'd be a great playground to learn about J2SE 1.5 features and 
> actually could be a textbook case for the use of covariant return types. 
>   I'm planning in my SD West conference talk in March to delve into 
> these possibilities.

1.0 first :-)

But after that I'm not so sure a generic JDOM is going to be as exciting as
it first sounds.  For example it would be great to get rid of the wrapped
lists like

    ContentList content = new ContentList();

    public List getContent();

and replace them with a generic version such as

    List<Content> content = new ArrayList<Content>(); // syntax?

    public List<Content> getContent();

unfortunately because of "live" lists that won't work, got to set that
parent :(  Which means we're still left with one of our biggest headaches,
the code to support "live" lists.


More information about the jdom-interest mailing list