[jdom-interest] detach() [eg]
philip.nelson at omniresources.com
philip.nelson at omniresources.com
Wed Apr 25 05:56:56 PDT 2001
> I can do better than both of these :-)
>
> Utilities.move(elementToBeMoved, newParentElement);
>
> A method like this can of course encapsulate either the one line
> version or the 10 line version.
>
> We can overload both arguments quite heavily to take care of all the
> different things we might want to move (Elements, Comments,
> ProcessingInstructions, etc.). We could even add an optional third
> argument to specify at what position in the new place we wanted the
> moved thing put.
Is it just me, or this starting to look like some sort of transformation api
:-)
Of course this would work. But to handle this one simple little case? Your
idea of putting detach on Document is simpler. And until a more general
purposes set of classes becomes a more important part of the api, what would
make me look there to get this done?
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.
So, can I go back to coding again?
More information about the jdom-interest
mailing list