[jdom-interest] detach() [eg]

Elliotte Rusty Harold elharo at metalab.unc.edu
Mon Apr 23 07:40:19 PDT 2001


At 10:48 PM -0400 4/22/01, Scott Means wrote:
>It seems to me that one of Jason's major objections is the need to catch a
>random new exception anytime he wants to use the .detach() method, e.g.:
>
>>  >} catch (IllegalXXXException e) {
>

OK. Here's another proposal that comes from still another direction, 
and avoids all exceptions. Suppose instead of letting a child detach 
itself from its parent we let the parent element detach the child. In 
other words the signature of the detach() method would now look 
something like this:

public void detach(Element toBeDetached)
public void detach(Comment toBeDetached)
public void detach(String toBeDetached)
public void detach(ProcessingInstruction toBeDetached)
public void detach(Entity toBeDetached)

We would simply not give Document a detach() method so the root 
element could not be detached and no exceptions would ever be thrown 
by detach()?  In fact when this discussion popped up this is how I 
thought the detach() method actually worked, and I was a little 
surprised when the JavaDoc told me otherwise.
-- 

+-----------------------+------------------------+-------------------+
| 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