Hi,
I've noticed some strange behavior when using a NodeList and was wondering if others might have noticed this as well, or can point out something that I'm doing wrong...
According to the java.sun.com specification,
NodeList.item( int index )
returns either the node at the specified position (starting from 0), or null if index isn't valid. Well, in my application I receive a NodeList from
org.apache.xpath.XPathAPI.selectNodeList(Node, String) but
a NullPointerException is apparently being thrown when I
query the NodeList with an index value that is out of bounds (from above). Hmmm..., the XPathAPI specification doesn't mention anything about any exception being thrown by this method, just that a value of null should be returned for an out of bounds index value. Why would a NullPointerException result?? A value of null and a NullPointerException are very different things... I'm not feeding this result into anything else that does throw an NPE exeption either, so there isn't any confusion there.
Thanks!!!
dora
p.s., people have often suggested that I take a look at the source code for certain classes, such as HashMap or (I'd assume) XPathAPI. I'm probably being dense here, but where can I get that?![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
I've noticed some strange behavior when using a NodeList and was wondering if others might have noticed this as well, or can point out something that I'm doing wrong...
According to the java.sun.com specification,
NodeList.item( int index )
returns either the node at the specified position (starting from 0), or null if index isn't valid. Well, in my application I receive a NodeList from
org.apache.xpath.XPathAPI.selectNodeList(Node, String) but
a NullPointerException is apparently being thrown when I
query the NodeList with an index value that is out of bounds (from above). Hmmm..., the XPathAPI specification doesn't mention anything about any exception being thrown by this method, just that a value of null should be returned for an out of bounds index value. Why would a NullPointerException result?? A value of null and a NullPointerException are very different things... I'm not feeding this result into anything else that does throw an NPE exeption either, so there isn't any confusion there.
Thanks!!!
dora
p.s., people have often suggested that I take a look at the source code for certain classes, such as HashMap or (I'd assume) XPathAPI. I'm probably being dense here, but where can I get that?