[jdom-interest] detach() [eg]
philip.nelson at omniresources.com
philip.nelson at omniresources.com
Wed Apr 18 11:03:18 PDT 2001
> Definitely better than <placeholder/>. I changed it to be
> <root-element-was-detached/>.
>
> Steven Keens wrote:
> > Have detach() throw a RuntimeException.
>
> I'd prefer the simple story that detach() always does a detach.
>
> Patrick Dowler wrote:
> > use Element.MISSING_ROOT_ELEMENT as the placeholder.
>
> Interesting idea, but to do it right you'd need a non-editable Element
> subclass and I think that's just too heavyweight for this small issue.
What if we had getRootElement() throw an Illegal<something>Exception when
the placeholder was there? Then it wouln't matter at all how the internal
state was kept. Other than to see if you have this bogus Document, I can't
see any valid reason you would want to get the root element. If you try to
output the document, you would get a meaningful error. If you can't be
sure, you can attempt to get the root element and use a try catch to do the
right thing. Meanwhile, everything else works exactly the same way.
Element.MISSING_ROOT_ELEMENT would have the meaningful text to use in the
exception and could be protected an it's presence gives you a nice location
to document the behaviour.
More information about the jdom-interest
mailing list