[jdom-interest] detach() [eg]

Jools jools at jools.org
Tue Apr 17 13:42:45 PDT 2001


Whilst working through the source code for Element.java I became
uncomfortable
with the detach() method.

    public Element detach() {
        Element p = getParent();
        if (p != null) {
            p.removeContent(this);
        }
        else {
            Document d = getDocument();
            if (d != null) {
                d.setRootElement(new Element("placeholder"));
            }
        }
        return this;
    }

Which means that if we detach a root element from Document it ends
up being a document with one root element <placeholder/>.

Do we really want this, or should we simply set the root Element to
null ?


--Jools



More information about the jdom-interest mailing list