[jdom-interest] detach() [eg]

Kenworthy, Edward edward.kenworthy at exchange.co.uk
Wed May 2 04:03:53 PDT 2001


Hi Noam

That only works if you know where its going to go at the time you detach it
from it's parent. In cut and paste (a fairly common piece of functionality
and one I plan on implementing) when you cut (an Element) it is in a
parentless state. It maye end up being, effectively deleted, or put back or
moved to a new parent that we don't know until paste happens (if it does).

element.detach() is perfect. I don't need to know the element's parent to
use it and having the document throw an ISE if I am silly enough to detach
the root and then try and do something with the document handles the only
possible error condition.

Edward

-----Original Message-----
From: Noam Tamim [mailto:noamt at yahoo.com]
Sent: 02 May 2001 01:04
To: jdom-interest at jdom.org
Subject: Re: [jdom-interest] detach() [eg]



As an alternative, how about a simple Element.moveTo(Element) and
Element.moveTo(Document) ?

 - Noam.



----- Original Message -----
From: "Elliotte Rusty Harold" <elharo at metalab.unc.edu>
To: <jdom-interest at jdom.org>
Sent: Monday, April 30, 2001 16:07
Subject: Re: [jdom-interest] detach() [eg]


> At 6:00 PM -0700 4/29/01, Jason Hunter wrote:
> >>  That's secondary to me at this point. I am
> >>  saying, though, that I think detach() on an Element would make me
think it
> >>  detaches an element from the object detach() is being invoked on.
> >
> >Luckily detach() takes no parameters so if that's your inclination (note
> >it's not my inclination) then you'll have to realize it doesn't work
> >that way.
> >
>
> I think Brett's correct here. The way I explain it to my students is that
> the customary order in OOP is
>
> subject.verb(object)
>
> element.detach() violates that common understanding, especially since
> detach is not a reflexive verb.
>
> I really see no need for detach() anymore. I think that
> parent.removeContent(child) is all that's necessary; and detach() as
> currently written is just plain confusing. If we absolutely must have
> that bit of syntax sugar, then the name should be changed to a verb
> that does commonly operate on it's subject, like element.breakAway()
> or some such; but I really don't think we need it.
>
> And of course removing detach() totally eliminates the problems of
> clients unintentionally detaching the root element of a document.
> --
>
> +-----------------------+------------------------+-------------------+
> | 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/     |
> +----------------------------------+---------------------------------+
> _______________________________________________
> To control your jdom-interest membership:
>
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com

_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com



More information about the jdom-interest mailing list