[jdom-interest] NoSuch*Exceptions in JDOM
Brett McLaughlin
brett.mclaughlin at lutris.com
Thu Jun 15 14:57:01 PDT 2000
Simon Rade wrote:
>
> Hi!
>
> 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
always do
List children = element.getChildren("elementName");
and check the list's length if you don't want to deal with an Exception.
-Brett
>
> Bye,
> Simon
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
--
Brett McLaughlin
Enhydra Strategist
Lutris Technologies
1200 Pacific Avenue
Santa Cruz, CA 95060
More information about the jdom-interest
mailing list