[ 
https://issues.apache.org/jira/browse/JCR-1402?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12573796#action_12573796
 ] 

mduerig edited comment on JCR-1402 at 2/29/08 7:48 AM:
-------------------------------------------------------------

Ok, I suggest the following for getAncestor (credits due to Angela):

- If the path is absolute, normalize and determine ancestor of given degree. 
Throw if this would result in a 'negative' path.
- If the path is relative just add an appropriate number of parent elements.

Together with my proposal for isAncestorOf and isDescendant this is in 
accordance with Angela's suggestion while still handling relative paths 
correctly (i.e. isAncestor(getAncestor()) == true). Moreover there is no 
problem for above usage patterns.



      was (Author: mduerig):
    Ok, I suggest the following for getAncestor (credits due to Angela):

- If the path is absolute, normalize and determine ancestor of given degree. 
Throw if this would result in a 'negative' path.
- If the path is relative just an appropriate number of parent elements.

Together with my proposal for isAncestorOf and isDescendant this is in 
accordance with Angela's suggestion while still handling relative paths 
correctly (i.e. isAncestor(getAncestor()) == true). Moreover there is no 
problem for above usage patterns.


  
> Path.getAncestor and Path.isAncestor are not symmetric
> ------------------------------------------------------
>
>                 Key: JCR-1402
>                 URL: https://issues.apache.org/jira/browse/JCR-1402
>             Project: Jackrabbit
>          Issue Type: Improvement
>          Components: jackrabbit-spi, jackrabbit-spi-commons
>    Affects Versions: 1.4
>            Reporter: Michael Dürig
>            Priority: Minor
>         Attachments: path.patch
>
>
> Although the method names refer to ancestors they operate on sub-paths. 
> Consider:
> PathFactory pf = PathFactoryImpl.getInstance();
> Path.Element p = pf.getParentElement();
> Path path = pf.create(new Path.Element[]{p, p});
> Path ancestor = path.getAncestor(1);
> assertFalse(ancestor.isAncestorOf(path) )  
> This is not what one would expect from looking an the method signatures. 
> I suggest to rename getAncestor to getSubPath, clarify the javadoc, and 
> deprecate getAncestorCount. 
> A patch follows.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to