[jdom-interest] detach() [eg]

Jason Hunter jhunter at collab.net
Mon Apr 23 22:16:04 PDT 2001


philip.nelson at omniresources.com wrote:
> Sure.  My problem is that if you follow Joe's idea and use null instead, in
> *that* case you get a NullPointerException.  I would rather have the
> unchecked IllegalStateException (I think Joe is right about that) that says
> "you don't have a root element bozo", meaning me of course.  In both cases,
> you can just call detach without checking for exceptions so long as your
> code is well tested.

Yep.

> <snip>
> 
> I'm not that interested in the String vs Text node argument at this point
> ;^)

Amen, brother.

> So, with a detach on document, you don't have the *unanticipated* null root
> element.  IllegalStateException vs NullPointerException?  I still say
> IllegalStateException and only if getRootElement is called.

I agree.  I think you'd have to throw ISE on doc.getMixedContent() too.

> > Could we dispense with .detach() altogether?  Can't you call
> > setParent(null)?
> 
> no, it's protected

Right, users aren't to mess with the tree structure directly.

-jh-



More information about the jdom-interest mailing list