[jdom-interest] NoSuch*Exceptions in JDOM

bob bob at werken.com
Mon Jun 19 16:57:17 PDT 2000

1) Overhead for try/catch:

	If you're talking C++, then yes.
	If we're speaking Java, then no.  It's like a normal
	return with an IsExceptional flag set, for the most
	part.  So, that's a moot point with Java.  

2) I've always just removed the attribute before setting it,
instead of testing for null/exception.  removal doesn't fail
if it doesn't exist, so it's always safe.  Dunno if that
technique would work for you, but it's a thought.


On Mon, 19 Jun 2000, Thomas M. Sasala wrote:

> 	I personally like returning null.  Catching exceptions has become
> a very serious PITA for us while processing attributes.  It's
> complicated,
> but we're merging elements - some have the attributes and some don't.
> It's
> a lot easier to test for null, add the attribute, and move than catch
> an exception.  Plus, isn't there a significant amount of overhead
> for a try/catch (just a rumor I remember reading about a number of
> years ago)?
> 	-Tom
> Dehar Rohit wrote:
> > 
> > support:
> > 
> > Returning a null is more java-like and thats what JDOM is intended to
> > be. The thingy coming nearest to getChild() is java.util.Hashtable's
> > get() method (it returns the value to which the specified key is
> > mapped in this hashtable). It doesn't throw a No*Exception, plainly
> > returns a null if the key is not found.
> > 
> > plus:
> > 
> > its easier to check nulls than an exception every time. i'd
> > personally prefer null returns for xpath type support too (is that
> > too early to talk of xpath?).
> > 
> > Rohit Dehar

More information about the jdom-interest mailing list