[Yanel-dev] exists() method for Node interface
Michael Wechner
michael.wechner at wyona.com
Tue Feb 13 15:59:11 CET 2007
Josias Thöny wrote:
> 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...
I don't think it returns a NullPointer, but rather wanted to make an
example why I think the exists method is nices than checking on
NullPointer or catching an exception.
Thanks for the help, now I know what I have to use :-)
Cheers
Michi
>
>> 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
>>>
>>
>>
>
>
> _______________________________________________
> Yanel-development mailing list
> Yanel-development at wyona.com
> http://wyona.com/cgi-bin/mailman/listinfo/yanel-development
>
--
Michael Wechner
Wyona - Open Source Content Management - Apache Lenya
http://www.wyona.com http://lenya.apache.org
michael.wechner at wyona.com michi at apache.org
+41 44 272 91 61
More information about the Yanel-development
mailing list