com.cc.framework.ui.model.imp
Class VirtualListDataModel

java.lang.Object
  extended bycom.cc.framework.ui.model.imp.VirtualListDataModel
All Implemented Interfaces:
DataModel, ListDataModel, java.io.Serializable, VirtualDataModel

public abstract class VirtualListDataModel
extends java.lang.Object
implements VirtualDataModel, ListDataModel, java.io.Serializable

List Data Model for display lists with a very large or unknown number of rows.

Version:
$Revision: 1.14 $
Author:
Harald Schulz
See Also:
Serialized Form

Field Summary
private  boolean keepRows
          This flag directs the list not to flush the rowset cache when a new rowset is loaded.
private  java.util.Vector rowset
          The elements of the currently loaded rowset
private  int rowsetIndex
          This is the index of the first row in the rowset.
private  int rowsetSize
          This member holds the size of the rowset.
private static long serialVersionUID
          Serial Version UID
private  int size
          The total number of elements.
private  int threshold
          Number of overlapping rows between rowsets to reduce page filtering
 
Constructor Summary
VirtualListDataModel()
          Constructor
VirtualListDataModel(int rowsetSize, boolean keepRows)
          Constructor
 
Method Summary
 int capacity()
          Returns the current capacity of this VirtualListDataModel.
 void clear()
          Clears the current list
protected  void clearRowset()
          Removes all elements from the rowset.
protected abstract  java.util.Collection doFetchRowset(int startIndex, int rowCount)
          This method reads a rowset into memory
protected  int doFetchSize()
          This method is called to fetch the actual rowset size.
protected  void doSetup()
          This method is called first to do any initialization processing
private  void fetchRowset(int index)
          This method is called when the next rowset is to be loaded into memory
 java.lang.Object getElementAt(int index)
          Returns the (row) object for the specified index.
 java.lang.Object getElementFromRowset(int index)
          Returns a Element of the rowset
 int getRowsetIndex()
          Returns the Index of the first element in the rowset
private  int mapIndexToRowSet(int index)
          This method maps an absolute index to a relative index in the rowset.
 void setRowsetSize(int i)
          Sets the rowset size to the specified value.
 void setSize(int i)
          Sets the number of total available elements in this list.
 void setThreshold(int i)
          Sets the threshold value.
 int size()
          Returns the number of rows within the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.cc.framework.ui.model.ListDataModel
getUniqueKey
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Serial Version UID

See Also:
Constant Field Values

keepRows

private boolean keepRows
This flag directs the list not to flush the rowset cache when a new rowset is loaded.


rowsetSize

private int rowsetSize
This member holds the size of the rowset. It should be larger than the number of displayed rows (but that is not necessary)


threshold

private int threshold
Number of overlapping rows between rowsets to reduce page filtering


size

private int size
The total number of elements. -1 when the correct number is unknown


rowsetIndex

private int rowsetIndex
This is the index of the first row in the rowset.


rowset

private java.util.Vector rowset
The elements of the currently loaded rowset

Constructor Detail

VirtualListDataModel

public VirtualListDataModel()
Constructor


VirtualListDataModel

public VirtualListDataModel(int rowsetSize,
                            boolean keepRows)
Constructor

Parameters:
rowsetSize - The number of records that should be fetched at a time
keepRows - Set to true when all rows should be kept in memory. Set to false when only a number of rowsetSize rows should be kept in memory (default)
Method Detail

clear

public void clear()
Clears the current list


clearRowset

protected void clearRowset()
Removes all elements from the rowset. The current rowset index is not affected.


fetchRowset

private void fetchRowset(int index)
                  throws java.lang.Exception
This method is called when the next rowset is to be loaded into memory

Parameters:
index - Start Index
Throws:
java.lang.Exception - Will be thrown in case of an error in the integration layer

doSetup

protected void doSetup()
                throws java.lang.Exception
This method is called first to do any initialization processing

Throws:
java.lang.Exception - Will be thrown in case of an error in the integration layer

doFetchSize

protected int doFetchSize()
                   throws java.lang.Exception
This method is called to fetch the actual rowset size. It's up to the derived class to provide an implementation or not

Returns:
Returns the size of the list or -1
Throws:
java.lang.Exception - Will be thrown in case of an error in the integration layer

doFetchRowset

protected abstract java.util.Collection doFetchRowset(int startIndex,
                                                      int rowCount)
                                               throws java.lang.Exception
This method reads a rowset into memory

Parameters:
startIndex - Index of the first row
rowCount - Number of rows to read
Returns:
Returns a collection of rowbeans
Throws:
java.lang.Exception - Will be thrown in case of an error in the integration layer

mapIndexToRowSet

private int mapIndexToRowSet(int index)
                      throws java.lang.Exception
This method maps an absolute index to a relative index in the rowset. When the relative index is outside the loaded rowset the missing data will be loaded dynamically to match the required index.

Parameters:
index - the absolute index
Returns:
returns the relative index or -1 when the index could not be matched
Throws:
java.lang.Exception - Will be thrown in case of an error in the integration layer

getElementAt

public java.lang.Object getElementAt(int index)
Description copied from interface: ListDataModel
Returns the (row) object for the specified index. This can be a display object (view helper) whose properties will be accessed within the columns of a List- or TreeControl

Specified by:
getElementAt in interface ListDataModel
Parameters:
index - A zero based index
Returns:
A row object.
See Also:
ListDataModel.getElementAt(int)

getElementFromRowset

public java.lang.Object getElementFromRowset(int index)
Returns a Element of the rowset

Parameters:
index - Element index in the rowset
Returns:
Row bean

size

public int size()
Description copied from interface: ListDataModel
Returns the number of rows within the list.

Specified by:
size in interface ListDataModel
Returns:
Number of rows
See Also:
ListDataModel.size()

capacity

public int capacity()
Returns the current capacity of this VirtualListDataModel.

Returns:
the current capacity (the length of its internal data array, kept in the field rowset of this VirtualListDataModel).

setSize

public void setSize(int i)
Sets the number of total available elements in this list.

Parameters:
i - Number of elements or -1 when the number is unknown

getRowsetIndex

public int getRowsetIndex()
Returns the Index of the first element in the rowset

Returns:
Index of the first element in the rowset

setRowsetSize

public void setRowsetSize(int i)
Sets the rowset size to the specified value. It should match the size of a database rowset for optimized data throughput.

Parameters:
i - new rowset size

setThreshold

public void setThreshold(int i)
Sets the threshold value. That is the number of overlapping rows between two adjacent rowsets. The threshold reduces page filtering when the user scrolls through the list.

Parameters:
i - new threshold value


Copyright © 2000-2005 SCC Informationssysteme GmbH. All Rights Reserved.