[jdom-interest] Convoluted Document Construction on b10

Jason Hunter jhunter at xquery.com
Wed Mar 31 16:21:58 PST 2004


It's well understood.  The reason is that Java doesn't have covariant 
return types so the new Parent interface's addContent() methods returns 
Parent and the Element implementation can't return the more specific 
type of Element.  You can do it in J2SE 1.5.

Options are: rip out the Parent interface, write an addContent(Parent) 
method as a nasty hack, keep it this way and have a J2SE 1.5 version.

-jh-

Stefano Santoro wrote:

> Hi,
> 
> I have been an avid fan of jdom-b9. I have recommended
> many of the vendors we work with to support jdom directly,
> and pushing all of my teams members that participate on
> various JSRs (XQuery, and JAXB) to champion further
> integration with JDOM.
> 
> So I was a bit taken back when I found out that JDOM b10
> no longer support elegant document constructions like this one
> 
>         Element webel = new Element("web-email", _wenfns);
> 
> 	webel.addContent
> 	  (new Element("message-id", _wenfns)
> 	   .addContent( Long.toString(req.getLegacyId())))
> 	  .addContent
> 	  (new Element( "sender", _wenfns)
> 	    .setAttribute( "address", req.getSender())
> 	    .addContent( "A Sender Dude"))
> 	  .addContent
> 	  (new Element( "recipient", _wenfns)
> 	   .setAttribute( "address", req.getRecipient())
> 	   .addContent( "A Recipient Dude"))
> 	  .addContent
> 	  (new Element( "subject", _wenfns)
> 	   .addContent(req.getSubject()));
> 
> Is this a planned disruption? Or is this being addressed?
> 
> Ciao
> Stefano
> 



More information about the jdom-interest mailing list