[jdom-interest] detach() [eg]

Jason Hunter jhunter at collab.net
Sat Apr 28 13:40:28 PDT 2001


Joseph Bowbeer wrote:
> 
> A more serious objection is the apparent absence of a state-testing method.
> I haven't seen concrete code for the ISE Document idea (hint hint), but as
> far as I can tell, the idea is that every accessor except setRootElement can
> throw ISE and that we aren't providing any direct way for the user to test
> if the Document is in an illegal state.

Note the Servlet API doesn't have a canGetWriter() method, it just
throws an ISE if you call getWriter() inappropriately.

> This sounds broken to me.  To fix this, we'd either need to let
> getRootElement return null, or we'd need to add a separate state-testing
> method.  Which one should it be?  Note that if getRootElement is allowed to
> return null, then ISE has lost much of its fail-fast capability (right?).

I don't think we need a hasRootElement() method.  I find it hard to
picture a time where you don't know the state of a Document wrt its
root.  The use case here is that someone is harvesting the root for use
in another document.  The original document is being thrown away.  In
the off chance the old doc is still referenced and is *accidentally*
used (prob due to programmer error), the doc's going to be smart enough
to point out to the caller that it's in an illegal state.

-jh-



More information about the jdom-interest mailing list