Hi guys,
is there an efficient way to find the node index (position) inside a parent
node?
At the moment I can only do in this way:
[code]/**
* Position is 0 based
*
* @param content
* @return
*/
public int getContentPosition(final Content parent, final Content
content) {
if (parent != null && content != null) {
final Collection<Content> children =
parent.getChildren();
final Iterator<Content> it = children.iterator();
int position = -1;
while (it.hasNext()) {
position++;
if (StringUtils.equals(it.next().getUUID(),
content.getUUID())) {
return position;
}
}
}
return -1;
}[/code]
Do you have any other solution? Something already implemented in Magnolia API?
Thanks a lot
Matteo
--
Context is everything:
http://forum.magnolia-cms.com/forum/thread.html?threadId=c61d27c2-4d7c-4cee-8c36-92d6521d71d6
----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------