[jdom-interest] Document changes tonight

Elliotte Rusty Harold elharo at metalab.unc.edu
Fri Aug 11 04:15:48 PDT 2000

At 2:30 AM -0700 8/11/00, Jason Hunter wrote:

>One thing I'm not sure about.  Do we need doc.addContent(Entity)?

No. An entity can't be the root, and can't exists outside the root. 
And you don't know if an entity only contains a single element or not.

>Also: What do people think about making the default Document()
>constructor public?  It's currently protected, and the logic for not
>having it public was that every document needed a root -- but then all
>over the place we call new Document(null) so we can construct the
>document in pieces like this:
>new Document(null)
>  .addContent(new Comment("before"))
>  .addContent(new Element("root"))
>  .addContent(new Comment("after"));
>We shouldn't have a null parameter to the constructor be some sort of
>secret enabler like this, imho.

You're right. But I recommend going in the other direction. The 
constructor should throw an exception, probably NullPointerException 
but maybe IllegalArgumentException if it's passed null as a root 

| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
|                  The XML Bible (IDG Books, 1999)                   |
|              http://metalab.unc.edu/xml/books/bible/               |
|   http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/   |
|  Read Cafe au Lait for Java News:  http://metalab.unc.edu/javafaq/ |
|  Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/     |

More information about the jdom-interest mailing list