[jdom-interest] getChildren() vs getElements()

Jason Hunter jhunter at collab.net
Fri Sep 15 20:47:32 PDT 2000

> > Wait a second.  The +1s are coming fast and furious but...
> You're right, I take mine back, this is more convoluted than 
> I thought,

Ha, why do you think we postponed the decision?  :-)

> > (*not* getChildElements(), unless there's a corresponding change to
> > getChildAttributes())
> I think I buy that (a tentative +1)

-50 on getChildAttributes().

> element.getElement("foo").getText();
> doesn't seem so bad. 

Except you're risking a NullPointerException.  That worked fine until
getChild() returned null if the child wasn't found.  You can read a long
email I wrote a couple months ago where I compared all the alternatives.

> Neither does something like ElemUtils.getText(Element
> elem, String childName) - one can write oneself a personal class 
> like that if it never showed up in JDOM itself.  

Except I want to include a cool JDOM example in my book.  And I'm not
about to use a personal class because what does that say about the API? 
It says it doesn't even solve a simple problem elegantly.

> Jason, I imagine, would have a stronger opinion on this.

There ya had it.  :-)


More information about the jdom-interest mailing list