[shrinkwrap-issues] [JBoss JIRA] Issue Comment Edited: (SHRINKDESC-84) Node.get(Patterns) matches recursive down the whole tree

Bartosz Majsak (JIRA) jira-events at lists.jboss.org
Mon Sep 5 06:05:26 EDT 2011


    [ https://issues.jboss.org/browse/SHRINKDESC-84?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12626159#comment-12626159 ] 

Bartosz Majsak edited comment on SHRINKDESC-84 at 9/5/11 6:04 AM:
------------------------------------------------------------------

Hi Andy, Aslak,

I worked on this task over the weekend and before making a pull request I just want to get some kind of the confirmation that my understanding was correct.

The patterns passed to in {{Query}} {code}T execute(Node node, Pattern... patterns){code} should form XPath-like query, shouldn't they? 
Considering following tree example:
{code}
root
  1
    1.1
      1.1.1
    1.2
  2
{code}
Query formed from two node names patterns {{/1/1.1.1}} should result with no match?

I introduced two implementations for {{GetQuery}} type, one dealing with absolute queries (which is actually desired one for mentioned cases here) and the other for relative paths. However I haven't seen any usage for the latter yet. Also the implementation is quite a naive matching algorithm. If you foresee usage on big trees I could introduce some kind of bottom-up matching algorithm which should perform better.

Looking forward for your feedback.

      was (Author: bmajsak):
    Hi Andy, Aslak,

I worked on this task over the weekend and before making a pull request I just want to get some kind of the confirmation that my understanding was correct.

The patterns passed to {code}T execute(Node node, Pattern... patterns){code} should form XPath-like query, shouldn't they? 
Considering following tree example:
{code}
root
  1
    1.1
      1.1.1
    1.2
  2
{code}
Query formed from two node names patterns {{/1/1.1.1}} should result with no match?

I introduced two implementations for {{GetQuery}} type, one dealing with absolute queries (which is actually desired one for mentioned cases here) and the other for relative paths. However I haven't seen any usage for the latter yet. Also the implementation is quite a naive matching algorithm. If you foresee usage on big trees I could introduce some kind of bottom-up matching algorithm which should perform better.

Looking forward for your feedback.
  
> Node.get(Patterns) matches recursive down the whole tree
> --------------------------------------------------------
>
>                 Key: SHRINKDESC-84
>                 URL: https://issues.jboss.org/browse/SHRINKDESC-84
>             Project: ShrinkWrap Descriptors
>          Issue Type: Bug
>          Components: spi
>    Affects Versions: 1.1.0-alpha-3
>            Reporter: Aslak Knutsen
>            Assignee: Bartosz Majsak
>            Priority: Blocker
>
> Node.get should only try to match the first level.
> {code}
>    @Test
>    public void shouldNotMatchAChildsChildrenOnGet() 
>    {
>       // /root/child1/child2
>       Node root = new Node(ROOT_NAME)
>             .createChild(CHILD_1_NAME)
>                .createChild(CHILD_2_NAME).getRoot();
>       Assert.assertNull(root.get(CHILD_2_NAME));
>    }
>    
>    @Test
>    public void shouldNotMatchAChildsChildrenOnGetSingle() 
>    {
>       // /root/child1/child2
>       Node root = new Node(ROOT_NAME)
>             .createChild(CHILD_1_NAME)
>                .createChild(CHILD_2_NAME).getRoot();
>       Assert.assertNull(root.getSingle(CHILD_2_NAME));
>    }
>    @Test
>    public void shouldNotMatchAChildsChildrenOnGetOrCreate() 
>    {
>       // /root/child1/child2
>       Node root = new Node(ROOT_NAME);
>       Node child1 = root.createChild(CHILD_1_NAME);
>       Node child2 = child1.createChild(CHILD_2_NAME);
>       Node createdChild = root.getOrCreate(CHILD_2_NAME);
>       Assert.assertNotSame(createdChild, child2);
>    }
>    @Test
>    public void shouldNotMatchAChildsChildrenOnRemoveChild() 
>    {
>       // /root/child1/child2
>       Node root = new Node(ROOT_NAME)
>             .createChild(CHILD_1_NAME)
>                .createChild(CHILD_2_NAME).getRoot();
>       Assert.assertNull(root.removeChild(CHILD_2_NAME));
>    }
>    @Test
>    public void shouldNotMatchAChildsChildrenOnRemoveChildren() 
>    {
>       // /root/child1/child2
>       Node root = new Node(ROOT_NAME)
>             .createChild(CHILD_1_NAME)
>                .createChild(CHILD_2_NAME).getRoot();
>       List<Node> removed = root.removeChildren(CHILD_2_NAME);
>       Assert.assertNotNull(removed);
>       Assert.assertEquals(0,  removed.size());
>    }
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the shrinkwrap-issues mailing list