[jdom-interest] NullPointerException... maybe change it?

Mike Hogarth mike at hogarth.org
Sun Jan 20 13:15:40 PST 2002


An attempt to get an Element with xyz.getChild("Name") when
the Element "Name" is not present in the XML document
results in a NullPointerException (ie, if tag Name is

JDOM developers might consider a more descriptive Exception
--- ElementNotFoundException: Name not found? 
to help debugging.

You might also consider a quick "search" method for the
Element name without having to traverse the nodes in
public boolean isElementPresent(Name){}

This allows one to quickly check to see if Elements are
present and to avoid any getChild(Name) method calls if the
element Name is not in the document.

--Mike H

More information about the jdom-interest mailing list