[jdom-interest] detach() [eg]

Jason Hunter jhunter at collab.net
Wed Apr 18 10:54:03 PDT 2001

Brett McLaughlin wrote:
> What if we made the name of that element more obvious that it was the result
> of a developer error, as that's what it is. Something like
> <missing-root-element/>
> or something. That would go a long way towards making me feel more
> comfortable here. Anyone else?

Definitely better than <placeholder/>.  I changed it to be

Steven Keens wrote:
> Have detach() throw a RuntimeException. 

I'd prefer the simple story that detach() always does a detach.

Patrick Dowler wrote:
> use Element.MISSING_ROOT_ELEMENT as the placeholder.

Interesting idea, but to do it right you'd need a non-editable Element
subclass and I think that's just too heavyweight for this small issue.

> It does seem that throwing an exception on root.detach() makes it hard
> for code to do some things: nuke current content, try to call GC, then
> create new content (alternative is to get rid of the Document as well,
> but it might contain  stuff one wants to keep...).

I agree with your thoughts on the problem of throwing an exception. 
It'd be interestig if we could "get rid of the document" but we can't
because someone else might have a reference to the doc and we can't
force them to give it up.


More information about the jdom-interest mailing list