[jdom-interest] detach() [eg]

Kenworthy, Edward edward.kenworthy at exchange.co.uk
Fri Apr 20 03:14:38 PDT 2001


The argument is that you're hiding a user error. Never, ever, a good idea.

-----Original Message-----
From: Joseph Bowbeer [mailto:jozart at csi.com]
Sent: 20 April 2001 11:03
To: jdom-interest at jdom.org
Subject: [jdom-interest] detach() [eg]


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




_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com



More information about the jdom-interest mailing list