org.alfresco.web.data
Class Sort

java.lang.Object
  extended by org.alfresco.web.data.Sort
Direct Known Subclasses:
MergeSort, QuickSort

public abstract class Sort
extends java.lang.Object

Sort Base sorting helper supports locale specific case sensitive, case in-sensitive and numeric data sorting.


Field Summary
protected  boolean bForward
          sort direction
protected  java.text.Collator collator
          locale sensitive collator
protected  java.lang.String column
          column name to sort against
protected  java.util.List data
          list of Object[] data to sort
protected  java.util.List keys
          collation keys for comparisons
protected  java.lang.String sortMode
          sort mode (see IDataContainer constants)
 
Constructor Summary
Sort(java.util.List data, java.lang.String column, boolean bForward, java.lang.String mode)
          Constructor
 
Method Summary
protected  java.util.List buildCollationKeys(java.text.Collator collator)
          Build a list of collation keys for comparing locale sensitive strings or build the appropriate objects for comparison for other standard data types.
protected  java.util.Comparator getComparator()
          Return the comparator to be used during column value comparison
protected static java.lang.String getGetterMethodName(java.lang.String name)
          Return the name of the Bean getter method for the specified getter name
abstract  void sort()
          Runs the Sort routine on the current dataset
protected  void swap(java.util.List v, int a, int b)
          Given the array and two indices, swap the two items in the array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

protected java.util.List data
list of Object[] data to sort


column

protected java.lang.String column
column name to sort against


bForward

protected boolean bForward
sort direction


sortMode

protected java.lang.String sortMode
sort mode (see IDataContainer constants)


collator

protected java.text.Collator collator
locale sensitive collator


keys

protected java.util.List keys
collation keys for comparisons

Constructor Detail

Sort

public Sort(java.util.List data,
            java.lang.String column,
            boolean bForward,
            java.lang.String mode)
Constructor

Parameters:
data - a the List of String[] data to sort
column - the column getter method to use on the row to sort
bForward - true for a forward sort, false for a reverse sort
mode - sort mode to use (see IDataContainer constants)
Method Detail

sort

public abstract void sort()
Runs the Sort routine on the current dataset


buildCollationKeys

protected java.util.List buildCollationKeys(java.text.Collator collator)
Build a list of collation keys for comparing locale sensitive strings or build the appropriate objects for comparison for other standard data types.

Parameters:
collator - the Collator object to use to build String keys

swap

protected void swap(java.util.List v,
                    int a,
                    int b)
Given the array and two indices, swap the two items in the array.


getComparator

protected java.util.Comparator getComparator()
Return the comparator to be used during column value comparison

Returns:
Comparator for the appropriate column data type

getGetterMethodName

protected static java.lang.String getGetterMethodName(java.lang.String name)
Return the name of the Bean getter method for the specified getter name

Parameters:
name - of the field to build getter method name for e.g. "value"
Returns:
the name of the Bean getter method for the field name e.g. "getValue"


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.