Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] nodes.insert(null)

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "Bradley S. Huffman" <hip AT cs.okstate.edu>
  • To: Elliotte Harold <elharo AT metalab.unc.edu>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] nodes.insert(null)
  • Date: Sun, 06 Feb 2005 10:05:23 -0600

Elliotte Harold writes:

> While considering the possibility of allowing Nodes objects to be
> canonicalized, it occurred to me to wonder whether the items in such a
> list could be null. Apparently, they can be. This test passes:
>
> public void testNull() {
>
> Nodes nodes = new Nodes();
> nodes.append(null);
> assertEquals(null, nodes.get(0));
>
> }
>
>
> I'm not sure I ever really thought about this before. If I had, I think
> I probably would have decided to throw a NullPointerException when
> someone tried to insert null into the list, but it's not a strong
> feeling. Now I'm equally weakly inclined to leave it alone; since it's
> possible changing this now might break someone's code.
>
> Still, it might be nice to have an absolute guarantee that the items in
> a Nodes list or never null.
>
> Would anyone care to argue one way or the other? i.e. that Nodes
> definitely should or definitely should not allow null values?

I view Nodes as a place holder for results, not slots to be filled or left
empty. When nodes.size() > 0, I think the right thing is to have at least
one actual Node. Throw the exception.

Brad




Archive powered by MHonArc 2.6.24.

Top of Page