[jdom-interest] detach() [eg]

Joseph Bowbeer jozart at csi.com
Fri Apr 20 03:02:43 PDT 2001


Ken Rune Helland writes:

> how about allowing the Document to have null as root
> but have it throw IllegalStateException on all methods
> except setRootElement.

All things being equal, I'd rather leave the check up to the client. That
is: I favor an illegal-argument in client over an illegal-state in document.
See my example of a builder client that would like to require that the root
hasn't been set yet.

What's the case for illegal-state of document over illegal-argument to
client?

The way I see it, only the document properties whose validity depends on the
root element should throw illegal-state if they are set before the root is
set.  Are there any of these?

Otherwise, only the client knows whether a document without a root is an
illegal argument -- and it's very easy for it to check.


----- Original Message -----
From: "Ken Rune Helland" <kenh at csc.no>
Sent: Friday, April 20, 2001 2:01 AM
Subject: Re: [jdom-interest] detach() [eg]

I think this was suggjested before; how about
allowing the Document to have null as root but have it
throw IllegalStateException on all metods except
setRootElement.

This will allow you to detach the root of a document
and throw the document away (which I guess is the most
usual ting to do with the Document after you detach the
root) and if you actually plan to use the Document object
it makes it quite clear if the programer somehow forgot
to set a new root element.


KenR







More information about the jdom-interest mailing list