[jdom-interest] NoSuch*Exceptions in JDOM
brett.mclaughlin at lutris.com
Thu Jun 15 14:57:01 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.
Yup. We went over this a bit - you don't want to ever have to really
check for null in code, it isn't that great of a practice. You can
List children = element.getChildren("elementName");
and check the list's length if you don't want to deal with an Exception.
> To control your jdom-interest membership:
1200 Pacific Avenue
Santa Cruz, CA 95060
More information about the jdom-interest