[jdom-interest] detach() [eg]

Patrick Dowler patrick.dowler at nrc.ca
Mon Apr 30 16:27:46 PDT 2001


On 30 April 2001 16:19, Patrick Dowler wrote:
> On 30 April 2001 07:07, Elliotte Rusty Harold wrote:
> > 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.
>
> The arguments in favour of detach appear to mainly be that it hides about
> 10-15 lines of case-checking code. It has been proposed that some utility
> methods would be useful, probably as static methods in a Util class:
>
> class JDOMUtil {
>
>    public static void move(Element movable, Element newParent) { }
>
> }

I should have clarified that I am agreeing with Elliote here: the move op
can be accomplished with the public API of Element without detach, so 
the above move() method can be coded using getParent(), removeContent(),
isRootElement(), etc quite easily. 

-- 
Patrick Dowler
Canadian Astronomy Data Centre
National Research Council
Victoria, BC



More information about the jdom-interest mailing list