Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.util
Class CollectionUtils

java.lang.Object
  extended by com.jivesoftware.util.CollectionUtils

public class CollectionUtils
extends java.lang.Object

Utilities to be used with java collection objects.


Nested Class Summary
static interface CollectionUtils.ListItemTransformer
          Collection modifying functor.
 
Method Summary
static void setNewIndex(java.util.List list, java.lang.Object o, int newIndex)
          Can be used to change the location of an item in a list.
static void setNewIndex(java.util.List list, java.lang.Object listItem, int newIndex, CollectionUtils.ListItemTransformer t)
          Exactly like setNewIndex without the transformer param, except this one will apply the transformer to every object that is adjusted in the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setNewIndex

public static void setNewIndex(java.util.List list,
                               java.lang.Object o,
                               int newIndex)
Can be used to change the location of an item in a list. The item MUST already be in the list.

If the newIndex is lower than the current index of the object then all object displaced will be moved up in the list until currentIndex is reached. If the newIndex is higher than the current index than all effect objects will be moved down until the current index is reached.

Parameters:
list - list to reorder an item
o - the item to reorder
newIndex - the new position the item will be at in the list

setNewIndex

public static void setNewIndex(java.util.List list,
                               java.lang.Object listItem,
                               int newIndex,
                               CollectionUtils.ListItemTransformer t)
Exactly like setNewIndex without the transformer param, except this one will apply the transformer to every object that is adjusted in the list. If the object does not need to be moved then the transformer will not be applied to it.

This is useful if the object in the list keeps track of its own index, which is a common for things like hibernate objects.

Parameters:
list - list to reorder an item
listItem - the item to reorder
t - transformer to be applied to every item that is adjusted in the list
newIndex - the new position the item will be at in the list

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.