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

Jason Hunter jhunter at xquery.com
Mon Feb 9 14:57:16 PST 2004


Robin Rosenberg wrote:
> On Monday 09 February 2004 00:45, Elliotte Rusty Harold wrote:
> 
>>At 6:10 PM -0700 2/8/04, Alex Rosen wrote:
>>
>>
>>>I feel the same way about Parent and Content, if they're likely to
>>>break any significant amount of user code. I haven't been following
>>>closely enough to know if that's the case or not.
>>
>>It wouldn't be likely to. These are very new with the latest beta. 
>>Almost nobody is using these. Changing these class names at this 
>>point would not be a problem.
> 
> 
> The name Parent/Child do not break anything, but having the method
> addContent return Parent instead of Element as it did in b9 breaks a lot of my code. 
> The fact that these methods returned the type Element was very convenient (and I
> see no reason for them to return anything, other than as a convenience measure.
> 
> -- robin

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.

-jh-




More information about the jdom-interest mailing list