Is this what you are looking for (written from top of my head not tested)?

Content me = MgnlContext.getHierarchyManager(ContentRepository.WEBSITE)
    .getContent(this.getConfigValue("your_node_name"));
Content last = null;
Iterator<Content> iter = me.getParent().getChildren().iterator();
while(iterator.hasNext() {
 last = iter.next();
}
return me.getName().equals(last.getName()) && me.getIndex()==last.getIndex
();

Cheers,
Jan


On 8/9/07, Philipp Bracher <[email protected]> wrote:
>
> > I am trying to create a method that would let me figure out if the
> > child is the last sibling of parent.
> > All is going well, I have some help from Jackrabbit user group
> > which recommended using following:
> >
> >
> >         NodeIterator iterator = parent.getJCRNode().getNodes();
> >         long siblingCount = iterator.getSize();
> >         iterator.skip(siblingCount-1);
> >         if (pSibling.getJCRNode().isSame(iterator.nextNode())) {
> >             return true; /* this is the last sibling */
> >         }
> >
> >
> >
> > Obviously, the code relies on JCR (NodeIterator.skip, isSame,etc,
> > etc)...
> >
> > Does Magnolia API has similar mothods classes I could use that
> > would not depend on using the JCR Node directly?
>
> Unfortunately not. We will work on that topic for future versions
> (making the magnolia api compatible with the jcr api). Till now you
> have to use the jcr api.
>
> Philipp Bracher
>
>
>
> ----------------------------------------------------------------
> for list details see
> http://documentation.magnolia.info/docs/en/editor/stayupdated.html
> ----------------------------------------------------------------
>

Reply via email to