[jdom-interest] NoSuch*Exceptions in JDOM

Alex Chaffee guru at edamame.stinky.com
Mon Jul 10 12:07:51 PDT 2000

> Hmm...  I'm pondering the approach of passing a second argument in case
> the element isn't found.  It's not pretty.  You get things like
> getChild("foo", null) that makes it look like you have a null namespace
> or something.

It doesn't look that way to someone who's never used namespaces with
JDOM (e.g. me).  It's not too late to change the API for using

>  Its advantages are that it follows the standard Java
> pattern for returning a default if something isn't located, and it would
> allow some advanced uses, for example getChild("foo",
> default).getContent() could return the content of the default element if
> "foo" wasn't found.

I'm growing to like this.  It sort of reminds me of my retarded
suggestion of making an "empty" element.

>  A serious disadvantage is that it gives an
> ambiguity error because getChild(String, Namespace) and getChild(String,
> Element) both match the getChild("foo", null) call.

Rearrange the parameter order for namespaces?

Alex Chaffee                       mailto:alex at jguru.com
jGuru - Java News and FAQs         http://www.jguru.com/alex/
Creator of Gamelan                 http://www.gamelan.com/
Founder of Purple Technology       http://www.purpletech.com/
Curator of Stinky Art Collective   http://www.stinky.com/

More information about the jdom-interest mailing list