[jdom-interest] BUG in Document

steven.gould at cgiusa.com steven.gould at cgiusa.com
Fri Feb 9 10:11:50 PST 2001


Frank Morton wrote:

> I'm a newbie (today), but really like what I see so far and will
> be happy to contribute significantly. I'm using code freshly
> checked out of CVS.
>
> If you do:
>
> Document doc = new Document();
> doc.setRootElement(new Element("something"));
>
> You get a NullPointerException because "content" is
> not initialized when using the no arg constructor.

Why not use the following:

Document doc = new Document( new Element("something") );

Won't this give you the intended result?

> So, I added the following to the first line of setRootElement(element):
>
> if(content == null) content = new LinkedList();
>
> Since I'm new to the code, don't know if this is the best way to
> do this. So, what is the process of bug fixing?
>
> Just to head this off, I need to be able to do it this way because
> I'm writing a class that extends Document, so it needs to construct
> the Document before it has a chance to create what is going to
> be the root element.
>
> Frank
>
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com



More information about the jdom-interest mailing list