[Yanel-dev] exists() method for Node interface

Josias Thöny josias.thoeny at wyona.com
Tue Feb 13 15:41:13 CET 2007


Michael Wechner wrote:
> Josias Thöny wrote:
> 
>> Michael Wechner wrote:
>>
>>> Hi
>>>
>>> It seems to me that we should add an "exists" method to 
>>> /org/wyona/yarep/core/Node.java
>>>
>>> WDYT?
>>
>>
>> No, because the Repository already has a method existsNode(path).
> 
> 
> I guess this what I was looking for
> 
>> If you have an instance of class Node, it means that it exists. You 
>> should not be able to get an instance of a node which does not exist.
> 
> 
> well, getNode(path).isCollection() will throw a NullPointerException 

Actually it's supposed to throw a NoSuchNodeException if the node does 
not exist. That it returnes null looks like a bug, and I guess it's 
related to fallback...

> when the node does not exist, hence I would like to test it first.
> Of course one could do something like
> 
> getNode(path) !=  null && getNode(path).isCollection()
> 
> but I think
> 
> existsNode(path) && getNode(path).isCollection()
> 
> is nicer ;-)

+1 for using existsNode.
As mentioned above, the null test should not be used because getNode 
actually should throw an Exception instead of returning null.

Josias

> 
> Thanks
> 
> Michi
> 
>>
>> hth,
>> Josias
>>
>>>
>>> Cheers
>>>
>>> Michi
>>>
>>
>>
>> _______________________________________________
>> Yanel-development mailing list
>> Yanel-development at wyona.com
>> http://wyona.com/cgi-bin/mailman/listinfo/yanel-development
>>
> 
> 




More information about the Yanel-development mailing list