jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jocsch <joc...@freaquac.de>
Subject Re: sibling and basic understanding of jsr 170
Date Mon, 13 Dec 2004 19:27:05 GMT
Thanks for the anwser. That's for sure not elegant. 
Hopefully some day I can replace this string manipulation with something 
cleaner ;-)

Greetings,
 Markus


Am Montag, 13. Dezember 2004 18:27 schrieb Stefan Guggisberg:
> hi markus,
> you're right, there's no easy solution for your particular use case,
>
> you could write a short utility method though, something like
>
> Node getSiblingOf(Node n, int index)
>
> that method would
>
> 1. extract the current subscript from the path of n (n.getPath()),
>     e.g. 99
> 2. compute new subscript (99-1=98)
> 3. get sibling with
>     n.getParent().getNode(n.getName() + "[" + subscript + "]")
>
> not very elegant but more efficient than iterating over all children...
>
> cheers
> stefan
>
> On Mon, 13 Dec 2004 18:04:46 +0100, jocsch <jocsch@freaquac.de> wrote:
> > Hi,
> >
> > sorry for posting a more jcr related question than a jackrabbit one, but
> > I'm not in the expert group ;-)
> >
> > I have a problem finding a sibling related to a given Node.
> > I set up a container node which has an undetermined number of children.
> > The order of the children matters. So it looks like:
> >
> > RN
> >
> >  tst:container
> >
> >     |-...
> >     |-tst:child[98]
> >     |-tst:child[99]
> >     |-....
> >
> > Now I have a use case where tst:child[99] is given and I need to show its
> > preceding sibling tst:child[98].
> > I found no possibility to get this node other than iterating over all
> > children (comparing to the given node and remembering the preceding
> > node), because it seems that there is no getPosition() or something like
> > that on the Node type.
> >
> > I think this solution is far from optimal. Is there a better solution?
> > OK, I guess I can implement a kind of a linked list functionality into
> > the child node types, but if possible, I want to avoid this.
> > I know that there are xpath functions like following-sibling but I read
> > somewhere that xpath queries are not yet implemented in jackrabbit.
> >
> > Thanks,
> >  Markus

Mime
View raw message