ariba.util.core
Class StableOrder

java.lang.Object
  extended by ariba.util.core.StableOrder

public abstract class StableOrder
extends Object

This is a class that persists a particular order of elements. It will be able to ensure that new elements are only added at the end of the existing ones. The order is persisted between server startups. The persistence is realm-aware based on the current session's realm.


Nested Class Summary
static interface StableOrder.StringRepresentation
           
 
Constructor Summary
StableOrder()
           
 
Method Summary
abstract  void clear()
          Re-set the order
abstract  List getElements()
          Returns the list of ordered elements (the string representations) contained in this order.
static StableOrder getOrder(String name)
          Get an instance of a stable order.
static void setFactory(ariba.util.core.StableOrder.StableOrderFactory theFactory)
           
 void setOrder(List newOrder)
          Force the order to be the same order as the passed in List
abstract  void setOrder(List newOrder, StableOrder.StringRepresentation representation)
          Force the order to be the same order as the passed in List
 List stableOrder(List original)
          Stable order for lists of strings
abstract  List stableOrder(List original, StableOrder.StringRepresentation representation)
          Return the original list in the order (named by the orderKey) any subsequent call to this method with this name results in the same order.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StableOrder

public StableOrder()
Method Detail

stableOrder

public List stableOrder(List original)
Stable order for lists of strings

See Also:
stableOrder(List, StringRepresentation)

stableOrder

public abstract List stableOrder(List original,
                                 StableOrder.StringRepresentation representation)
Return the original list in the order (named by the orderKey) any subsequent call to this method with this name results in the same order. This method is expected to be slow. Any new elements in the list will be added to the end of the resultant list (and the persisted order) in the order they appear in the original list. So: stableOrder({"a", "d", "e"}) -> {"a","d","e"} stableOrder({"d", "a", "e"}) -> {"a","d","e"} stableOrder({"d", "b", "a", "c", "e"}) -> {"a", "d", "e", "b", "c"} Use this for small lists (hundreds) not large lists (thousands) Note: duplicate entries in the original list will be removed!

Parameters:
original - Original list
representation - Used to map objects to strings (uniquely) (or null to use toString)
Returns:
Sorted list

getElements

public abstract List getElements()
Returns the list of ordered elements (the string representations) contained in this order.

Returns:
the list of string elements being ordered in their order

clear

public abstract void clear()
Re-set the order


setOrder

public void setOrder(List newOrder)
Force the order to be the same order as the passed in List

Parameters:
newOrder - Order

setOrder

public abstract void setOrder(List newOrder,
                              StableOrder.StringRepresentation representation)
Force the order to be the same order as the passed in List

Parameters:
newOrder - Order
representation - a mapping to map the element objects to strings

setFactory

public static void setFactory(ariba.util.core.StableOrder.StableOrderFactory theFactory)

getOrder

public static StableOrder getOrder(String name)
Get an instance of a stable order. The instance is realm-specific.

Parameters:
name - A name for the order
Returns:
An object that manages the named ordering


AribaWeb User Interface Development Framework
Copyright © 2000-2009 Ariba, Inc. All Rights Reserved.