com.webmethods.caf.faces.data.object
Class SortInfo

java.lang.Object
  extended by com.webmethods.caf.faces.data.object.SortInfo
All Implemented Interfaces:
ISortInfo, Serializable

public class SortInfo
extends Object
implements ISortInfo, Serializable

Implementation of table sort information bean.

See Also:
Serialized Form

Nested Class Summary
 class SortInfo.AscendingsContentProvider
          Maps column keys to ascending values.
static class SortInfo.Ordinal
           
 class SortInfo.OrdinalsContentProvider
          Maps column keys to ordinal values.
 
Field Summary
protected  List m_ordinals
           
 
Constructor Summary
SortInfo()
          New, empty sort info constructor
SortInfo(ISortInfo sort)
          Shallow copy of existing sort info.
SortInfo(String s)
          Sort info from SortInfo.toString() (with string keys).
 
Method Summary
 void add(int ordinal, Object key, boolean ascending)
          Adds an ordinal.
 void add(Object key, boolean ascending)
          Adds as last ordinal.
 void clear()
          Removes all ordinals.
 boolean equals(Object o)
           
 void fromString(String s)
          Reverses SortInfo.toString() (with string keys).
 IContentProvider getAscendings()
          Return content provider for mapping keys to ascending values.
 Object getKey(int ordinal)
          Sort key.
protected  SortInfo.Ordinal getOrdinal(int ordinal)
           
 int getOrdinal(Object key)
          Sort ordinal associated with specified key.
 IContentProvider getOrdinals()
          Return content provider for mapping keys to ordinal values.
 int hashCode()
           
 boolean isAscending(int ordinal)
          Sort order.
 boolean isAscending(Object key)
          Sort order associated with specified key.
 void move(int fromOrdinal, int toOrdinal)
          Moves from first ordinal to second ordinal.
 void remove(int ordinal)
          Removes an ordinal.
 int size()
          Return number of sort keys.
 void toggleAscending(int ordinal)
          Toggles between ascending and descending for ordinal.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

m_ordinals

protected List m_ordinals
Constructor Detail

SortInfo

public SortInfo()
New, empty sort info constructor


SortInfo

public SortInfo(String s)
Sort info from SortInfo.toString() (with string keys).


SortInfo

public SortInfo(ISortInfo sort)
Shallow copy of existing sort info.

Method Detail

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

size

public int size()
Description copied from interface: ISortInfo
Return number of sort keys. May be zero.

Specified by:
size in interface ISortInfo
Returns:
number of sort keys

getKey

public Object getKey(int ordinal)
Description copied from interface: ISortInfo
Sort key. The 1st key is the primary key, the 2nd key is the secondary key, etc.

Specified by:
getKey in interface ISortInfo
Parameters:
ordinal - Must be > 0 and <= ISortInfo.size().
Returns:
Non-null, non-empty key.

isAscending

public boolean isAscending(int ordinal)
Description copied from interface: ISortInfo
Sort order. The 1st order is the primary order, the 2nd order is the secondary order, etc.

Specified by:
isAscending in interface ISortInfo
Parameters:
ordinal - Must be > 0 and <= ISortInfo.size().
Returns:
True if order is a-z, 1-10, Jan-Dec, etc.

isAscending

public boolean isAscending(Object key)
Description copied from interface: ISortInfo
Sort order associated with specified key.

Specified by:
isAscending in interface ISortInfo
Parameters:
key - the sort key.
Returns:
True if order is a-z, 1-10, Jan-Dec, etc., or if key is not present.

getOrdinal

public int getOrdinal(Object key)
Description copied from interface: ISortInfo
Sort ordinal associated with specified key.

Specified by:
getOrdinal in interface ISortInfo
Parameters:
key - sort ordinal
Returns:
Ordinal, or zero if key is not present.

getOrdinals

public IContentProvider getOrdinals()
Description copied from interface: ISortInfo
Return content provider for mapping keys to ordinal values.

Specified by:
getOrdinals in interface ISortInfo
Returns:
instance of SortInfo.OrdinalsContentProvider

getAscendings

public IContentProvider getAscendings()
Description copied from interface: ISortInfo
Return content provider for mapping keys to ascending values.

Specified by:
getAscendings in interface ISortInfo
Returns:
instance of SortInfo.AscendingsContentProvider

toggleAscending

public void toggleAscending(int ordinal)
Toggles between ascending and descending for ordinal.


add

public void add(Object key,
                boolean ascending)
Adds as last ordinal.

Parameters:
key - Non-null, non-empty key.
ascending - True if order is a-z, 1-10, Jan-Dec, etc.

add

public void add(int ordinal,
                Object key,
                boolean ascending)
Adds an ordinal. The 1st key is the primary key, the 2nd key is the secondary key, etc.

Parameters:
ordinal - Must be > 0 and <= SortInfo.size().
key - Non-null, non-empty key.
ascending - True if order is a-z, 1-10, Jan-Dec, etc.
Throws:
IndexOutOfBoundsException - If ordinal <= 1 or > SortInfo.size() + 1.

remove

public void remove(int ordinal)
Removes an ordinal. The 1st key is the primary key, the 2nd key is the secondary key, etc.

Parameters:
ordinal - Must be > 0 and <= SortInfo.size().
Throws:
IndexOutOfBoundsException - If ordinal <= 1 or > SortInfo.size().

move

public void move(int fromOrdinal,
                 int toOrdinal)
Moves from first ordinal to second ordinal.

Parameters:
fromOrdinal - Must be > 0 and <= SortInfo.size().
toOrdinal - Must be > 0 and <= SortInfo.size().
Throws:
IndexOutOfBoundsException - If either ordinal <= 1 or > SortInfo.size().

clear

public void clear()
Removes all ordinals.


fromString

public void fromString(String s)
Reverses SortInfo.toString() (with string keys).


getOrdinal

protected SortInfo.Ordinal getOrdinal(int ordinal)
Parameters:
ordinal - Must be > 0 and <= SortInfo.size().
Returns:
Ordinal object.
Throws:
IndexOutOfBoundsException - If ordinal <= 1 or > SortInfo.size().