jackrabbit-oak-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Dürig <mdue...@apache.org>
Subject Re: Regarding NullLocation#getParent (was Re: svn commit: r1440930)
Date Thu, 31 Jan 2013 13:33:42 GMT


On 31.1.13 13:08, Angela Schreiber wrote:
> hi michael
>
> while looking at the TreeLocation implementation was wondering about
> NullLocation#getParent() as IMO it violates the API contract because
> it always returns the NULL-location. is there a particular reason
> for this? and wouldn't it be possible to return the original
> parent location through which this NULL location had originally
> be accessed? to me that would feel much more natural that having
> a location that all in a sudden is isolated from the hierarchy.
>
> what do you think?

The intention of NullLocation was to indicate that the path of 
navigation through which the NullLocation was obtained is invalid. But 
it is true that this somewhat contradicts the contract of getParent().

If we change this the way you propose, we need to keep track of a 
potential hierarchy of NullLocations. I.e. in the case someone calls 
getChild() on a NullLocation. If we do that, we should also change the 
contract of getPath() to not return null for NullLocations but rather 
the path of that location. Otherwise it is a bit funny that you can 
navigate from a location with a null path up the hierarchy to a location 
with a non null path.

Michael





>
> regards
> angela
>
>> +    /**
>> +     * @return  {@code NULL}
>> +     */
>> +    @Override
>> +    public TreeLocation getParent() {
>> +        return NULL;
>> +    }
>

Mime
View raw message