[jdom-interest] detach() [eg]
edward.kenworthy at exchange.co.uk
Fri Apr 20 02:37:18 PDT 2001
From: Ken Rune Helland [mailto:kenh at csc.no]
Sent: 20 April 2001 10:01
To: Jason Hunter; Joseph Bowbeer
Cc: jdom-interest at jdom.org
Subject: Re: [jdom-interest] detach() [eg]
>I think this was suggjested before;
I did ;-)
> how about
>allowing the Document to have null as root but have it
>throw IllegalStateException on all metods except
Yep and I still think its the best approach and most in keeping with Java in
particular and OO programming in general.
>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.
Exactly ! Instead of hiding the programmer's mistake it makes it explicit.
Which would you prefer: A library that hides your mistakes and makes it
difficult to track them down - or one that makes them explicit ?
At 01:04 AM 4/20/2001 -0700, Jason Hunter wrote:
>Joseph Bowbeer wrote:
> > I wonder, too.
> > Adding a place-holder may preserve the well-formedness of the document,
> > it probably doesn't preserve the validity.
> > If we can have root Elements with no associated Document and non-root
> > Elements with no parent, what's so bad about Documents without roots?
>Under the current design, what a developer can trust is: Any JDOM
>Document is a well-formed document, and any JDOM Element is a
>well-formed document fragment. So if you're writing an outputter or doc
>manipulator, you know you don't have to check any well-formedness.
>It'll be checked for you.
>Note you can't really have a root element with no associated document.
>If there's no doc, it's not a root element, it's just an element.
>Yes, it's ugly to have a root replacement added. It's also ugly to
>break the well-formedness contract. Which one's less ugly?
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
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.
To control your jdom-interest membership:
More information about the jdom-interest