com.plumtree.uiinfrastructure.arraywrapper
Class PTSortedArrayWrapper

java.lang.Object
  extended by com.plumtree.uiinfrastructure.arraywrapper.PTSortedArrayWrapper
Direct Known Subclasses:
APTQueryWrapper, PTGrowableSortedArrayWrapper

public class PTSortedArrayWrapper
extends java.lang.Object

MES- The PTSortedArrayWrapper class wraps a 2D Object array. It allows a client to re-sort the rows in the array by multiple columns in a performant way. Additionally, it allows addressing of columns by ID, rather than index (for example, if col 0 is NAME and col 1 is DESC, a client can ask for the NAME for row 2, rather than asking for col 0.)

Version:
1.0
Author:
MichaelS

Field Summary
protected  java.lang.Object[][] m_arrData
          MES- m_arrData stores the actual data
protected  int[][] m_arrSort
          MES- m_arrSort stores the current sort we're displaying
protected  boolean m_bSortOptimized
          MES- When the data is correctly sorted according to m_arrSort, we can skip the step of dereferencing rows through m_lstRowMapping.
protected  XPHashtable m_hashPropIDtoColumn
          MES- m_hashPropIDtoColumn stores a map of Property ID to the column that contains data for that property.
protected  XPArrayList m_lstRowMapping
          MES- m_lstRowMapping holds the row numbers.
static int PTSAW_NEWITEMSINFO_INDEX
          JF- This is used by the SetItems method.
static int PTSAW_NEWITEMSINFO_NEWVALUE
          JF- This is used by the SetItems method.
static int PTSAW_NEWITEMSINFO_PROPERTYID
          JF- This is used by the SetItems method.
static int PTSAW_SORT_ASCENDING
          MES- PTSAW_SORT_ASCENDING indicates that a column is sorted ascending
static int PTSAW_SORT_DESCENDING
          MES- PTSAW_SORT_DESCENDING indicates that a column is sorted descending
static int PTSAW_SORT_ROW_DIRECTION
          MES- Sort direction is indicated via a 2D array.
static int PTSAW_SORT_ROW_PROPID
          MES- Sort direction is indicated via a 2D array.
 
Constructor Summary
PTSortedArrayWrapper()
           
 
Method Summary
 boolean ContainsPropID(int iPropID)
          MES- ContainsPropID is used by clients to see if a given Property is represented by a column in the data.
 int GetCount()
          MES- GetCount returns the number of rows in our data set
 java.lang.Object GetItem(int iRow, int iPropID)
          MES- GetItem is used by clients to retrieve data from the array
 int[][] GetSort()
          MES- GetSort returns the current sort array
 void Initialize(int[] arrColumnIDs, java.lang.Object[][] arrData, int[][] arrSort, boolean bRequiresSort)
          MES- Initialize sets up this object with the data it needs to return items, as well as to perform sorts, etc.
protected  void MapColumnIDs(int[] arrColumnIDs)
          MES- MapColumnIDs is an internal function that sets up the m_hashPropIDtoColumn mapping based on an array of ColumnIDs
 void SetItem(int iRow, int iPropID, java.lang.Object oItem)
          JF- SetItem is used by clients modify one cell in the array.
 void SetItems(java.lang.Object[][] arrNewItemsInfo)
          JF- SetItems is used by clients modify a number of cells in the array.
 void Sort(int[][] arrSort)
          MES- Sort is used by clients to resort the internal data according to new criteria.
protected  void SortInternal()
          MES- SortInternal is an internal helper function that actually performs the sort based on m_arrSort.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PTSAW_SORT_ASCENDING

public static final int PTSAW_SORT_ASCENDING
MES- PTSAW_SORT_ASCENDING indicates that a column is sorted ascending

See Also:
Constant Field Values

PTSAW_SORT_DESCENDING

public static final int PTSAW_SORT_DESCENDING
MES- PTSAW_SORT_DESCENDING indicates that a column is sorted descending

See Also:
Constant Field Values

PTSAW_SORT_ROW_PROPID

public static final int PTSAW_SORT_ROW_PROPID
MES- Sort direction is indicated via a 2D array. PTSAW_SORT_ROW_PROPID identifies the row in the array that stores the Property ID to sort by.

See Also:
Constant Field Values

PTSAW_SORT_ROW_DIRECTION

public static final int PTSAW_SORT_ROW_DIRECTION
MES- Sort direction is indicated via a 2D array. PTSAW_SORT_ROW_DIRECTION identifies the row in the array that stores the sort direction, which should store PTSAW_SORT_ASCENDING or PTSAW_SORT_DESCENDING.

See Also:
Constant Field Values

PTSAW_NEWITEMSINFO_INDEX

public static final int PTSAW_NEWITEMSINFO_INDEX
JF- This is used by the SetItems method. The new items info (row index, prop ID and new cell value) is a 2D array. PTSAW_NEWITEMSINFO_INDEX identifies the column in the array that stores the row index of the cell to modify.

See Also:
Constant Field Values

PTSAW_NEWITEMSINFO_PROPERTYID

public static final int PTSAW_NEWITEMSINFO_PROPERTYID
JF- This is used by the SetItems method. The new items info (row index, prop ID and new cell value) is a 2D array. PTSAW_NEWITEMSINFO_COLUMNID identifies the column in the array that stores the column of the cell to modify.

See Also:
Constant Field Values

PTSAW_NEWITEMSINFO_NEWVALUE

public static final int PTSAW_NEWITEMSINFO_NEWVALUE
JF- This is used by the SetItems method. The new items info (row index, prop ID and new cell value) is a 2D array. PTSAW_NEWITEMSINFO_NEWVALUE identifies the column in the array that stores the new cell value.

See Also:
Constant Field Values

m_lstRowMapping

protected XPArrayList m_lstRowMapping
MES- m_lstRowMapping holds the row numbers. When we do a sort, we rearrange the items in m_lstRowMapping, but we do NOT rearrange the data itself. This layer of indirection lets us resort easily and relatively cheaply.


m_hashPropIDtoColumn

protected XPHashtable m_hashPropIDtoColumn
MES- m_hashPropIDtoColumn stores a map of Property ID to the column that contains data for that property. Note that the map points to the actual column object.


m_arrData

protected java.lang.Object[][] m_arrData
MES- m_arrData stores the actual data


m_arrSort

protected int[][] m_arrSort
MES- m_arrSort stores the current sort we're displaying


m_bSortOptimized

protected boolean m_bSortOptimized
MES- When the data is correctly sorted according to m_arrSort, we can skip the step of dereferencing rows through m_lstRowMapping. m_bSortOptimized holds a boolean to indicate if we can skip the dereferencing.

Constructor Detail

PTSortedArrayWrapper

public PTSortedArrayWrapper()
Method Detail

ContainsPropID

public boolean ContainsPropID(int iPropID)
MES- ContainsPropID is used by clients to see if a given Property is represented by a column in the data.

Parameters:
iPropID - is the ID of the Property
Returns:
a boolean indicating if the Property is found

GetCount

public int GetCount()
MES- GetCount returns the number of rows in our data set

Returns:
the number of rows

GetItem

public java.lang.Object GetItem(int iRow,
                                int iPropID)
MES- GetItem is used by clients to retrieve data from the array

Parameters:
iRow - indicates the row that's desired. That's the SORTED row, rather than the RAW row. GetItem will dereference the row number to figure out the real, raw row.
iPropID - indicates the Property that the client wants
Returns:
the item found with row iRow and Property iPropID, as an Object

GetSort

public int[][] GetSort()
MES- GetSort returns the current sort array

Returns:
the sort array, as passed into Initialize or Sort

Initialize

public void Initialize(int[] arrColumnIDs,
                       java.lang.Object[][] arrData,
                       int[][] arrSort,
                       boolean bRequiresSort)
MES- Initialize sets up this object with the data it needs to return items, as well as to perform sorts, etc.

Parameters:
arrColumnIDs - contains the Property IDs for each column in arrData. The size of arrColumnIDs should be equal to the number of columns in arrData.
arrData - contains the actual data to be stored and manipulated. The index convention matches the Plumtree server- the first index is column, and the second is the row, like arrData[iColIndex][iRowIndex]
arrSort - is a 2D int array of PropertyIDs to sort by. It should contain a column for each sort. The first row holds the PropertyID, and the second row holds the sort direction, PTSAW_SORT_ASCENDING or PTSAW_SORT_DESCENDING
bRequiresSort - indicates if arrData is already sorted as indicated by arrSort. If the client knows that the data is already sorted, we can skip the sort, and we can also optimize access.
Throws:
XPException - when arguments are not valid.

SetItem

public void SetItem(int iRow,
                    int iPropID,
                    java.lang.Object oItem)
JF- SetItem is used by clients modify one cell in the array.

Parameters:
iRow - indicates the row of the cell to modify. That's the SORTED row, rather than the RAW row. SetItem will dereference the row number to figure out the real, raw row.
iPropID - indicates the Property that the client wants to modify
oItem - is the new Object to set in the cell defined with iRow and iPropID

SetItems

public void SetItems(java.lang.Object[][] arrNewItemsInfo)
JF- SetItems is used by clients modify a number of cells in the array.

Parameters:
arrNewItemsInfo - This is a 2D array containing the row index, prop ID and new cell value of each cell to modify. Use the PTSAW_NEWITEMSINFO_ constant to build the array.

Sort

public void Sort(int[][] arrSort)
MES- Sort is used by clients to resort the internal data according to new criteria.

Parameters:
arrSort - is a 2D int array of PropertyIDs to sort by. It should contain a column for each sort. The first row holds the PropertyID, and the second row holds the sort direction, PTSAW_SORT_ASCENDING or PTSAW_SORT_DESCENDING.
Throws:
XPException - when arguments are not valid.

MapColumnIDs

protected void MapColumnIDs(int[] arrColumnIDs)
MES- MapColumnIDs is an internal function that sets up the m_hashPropIDtoColumn mapping based on an array of ColumnIDs

Parameters:
arrColumnIDs - is an array of column IDs. It should contain one int for each column in m_arrData, and may identify the column in any way the client desires.

SortInternal

protected void SortInternal()
MES- SortInternal is an internal helper function that actually performs the sort based on m_arrSort.




Copyright © 2002,2003,2004,2005 Plumtree Software, Inc., All Rights Reserved.