You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by Davide Giannella <gi...@gmail.com> on 2014/01/31 11:55:31 UTC

Iterating nodes from NodeBuilder

Good morning everyone,

I have the need to perform a custom iteration on child nodes based on
a custom property starting from the NodeBuilder. I'm working at
oak-core level.

I'm implementing a LinkedList approach in the repository therefore I
have something like

{
    :next = node1,
    node2 : {
        :next = <nowhere-last-element>
    },
    node1 : {
        :next = node2
    }
}

(intentionally shuffled the node representation)

from this I could fetch the next node by
Nodebuilder.getChildNode(<whateverinnext>).

I didn't find any iterator() (or similar) method at the
NodeBuilder/State level and therefore going to implement a custom
method in my class that need this approach but if you have any better
suggestion I'm more than happy :)

Thank you
Regards
Davide

Re: Iterating nodes from NodeBuilder

Posted by Davide Giannella <gi...@gmail.com>.
On 31/01/2014 15:56, Jukka Zitting wrote:
> You might want to take a look at AbstractTree.getChildNames(), where
> we've implemented a similar custom ordering of child nodes using the
> special :childOrder property. This mechanism is used to implement
> orderable nodes at the JCR level. 
Done already :)

>> I didn't find any iterator() (or similar) method at the
>> NodeBuilder/State level
> We usually return Iterables instead of Iterators. See getChildNames()
> and getChildNodeEntries(), the latter of which is only available on
> NodeState.
>
found it later on, forgot to follow up on the list.

Thanks
Davide



Re: Iterating nodes from NodeBuilder

Posted by Jukka Zitting <ju...@gmail.com>.
Hi Davide,

On Fri, Jan 31, 2014 at 5:55 AM, Davide Giannella
<gi...@gmail.com> wrote:
> I have the need to perform a custom iteration on child nodes based on
> a custom property starting from the NodeBuilder. I'm working at
> oak-core level.

You might want to take a look at AbstractTree.getChildNames(), where
we've implemented a similar custom ordering of child nodes using the
special :childOrder property. This mechanism is used to implement
orderable nodes at the JCR level.

> I didn't find any iterator() (or similar) method at the
> NodeBuilder/State level

We usually return Iterables instead of Iterators. See getChildNames()
and getChildNodeEntries(), the latter of which is only available on
NodeState.

BR,

Jukka Zitting