[jdom-interest] NoSuch*Exceptions in JDOM

Dave Hurrell dave at greatchiro.com
Thu Jul 13 01:37:15 PDT 2000

Simon Rade wrote:

> Element's methods getAttribute() and getChild() now throws
> NoSuchElementException and NoSuchAttributeException.
> Do you think this is better than returning null in such cases?
> Since it often happens that you don't know whether child or attribute
> exists and it is very awkward to handle those Exceptions. -Simon

The question is flawed; neither of your alternatives are good
design   No exceptions should be thrown and "the value" or
"a default value" should always be returned.  There should
be a separate method to query Element or Attribute objects
for whether the data exists.  Existence and content should be
mutually independent.  --GreatOne

More information about the jdom-interest mailing list