[jdom-interest] detach() [eg]

Elliotte Rusty Harold elharo at metalab.unc.edu
Wed Apr 25 08:52:37 PDT 2001

At 7:56 AM -0500 4/25/01, philip.nelson at omniresources.com wrote:

>It seems to me we have a growing consensus here.
>1 - detach becomes the responsibility of the parent and takes an argument of
>the content to be detached.
>2 - detaching a root element from document will put the document into an
>illegal state and the IllegalStateException will be thrown by getRootElement
>and getMixedContent
>3 - after the root element is detached, it will internally be set to null.

I agree with 1 but not 2 and 3. I simply don't see why we have to 
allow a document to detach its root without providing a plausible 

I suspect IllegalStateException was intended for situations where 
thread issues could leave an object in an illegal state; e.g. a 
thread finished half an update before it was interrupted. The JavaDoc 
for this class states that this method, "Signals that a method has 
been invoked at an illegal or inappropriate time. In other words, the 
Java environment or Java application is not in an appropriate state 
for the requested operation." Note the emphasis on time. The 
implication is that at a later time this condition will have been 

I also don't see why we should give programmers a method that, thread 
issues aside, deliberately puts an object into an illegal state.

| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
|                  The XML Bible (IDG Books, 1999)                   |
|              http://metalab.unc.edu/xml/books/bible/               |
|   http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/   |
|  Read Cafe au Lait for Java News:  http://metalab.unc.edu/javafaq/ |
|  Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/     |

More information about the jdom-interest mailing list