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

java.lang.Object
  extended bycom.cc.framework.ui.model.imp.VirtualTreeGroupDataModel
All Implemented Interfaces:
DataModel, TreeGroupDataModel, TreeNodeDataModel, VirtualDataModel

public abstract class VirtualTreeGroupDataModel
extends java.lang.Object
implements VirtualDataModel, TreeGroupDataModel

Tree Group Node for Nodes with with a very large or unknown number of rows.

Version:
$Revision$
Author:
Harald Schulz

Field Summary
private  boolean keepRows
          This flag directs the node 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  int size
          The total number of elements.
private  int threshold
          Number of overlapping rows between rowsets to reduce page filtering
 
Constructor Summary
VirtualTreeGroupDataModel()
          Constructor
VirtualTreeGroupDataModel(int rowsetSize, boolean keepRows)
          Constructor
 
Method Summary
 void addChild(TreeNodeDataModel child)
          Adds a new node to the child list Note: This method will also set the parent link of the new child node to this
 int capacity()
          Returns the current capacity of this VirtualTreeGroupDataModel.
 void clear()
          Clears the current node
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
 TreeNodeDataModel getChild(int index)
          Returns the node for the specified index
 TreeNodeDataModel 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 node.
 void setThreshold(int i)
          Sets the threshold value.
 int size()
          Returns the number of children for this node return -2 when the node has children but the user is not allowed to open the node.
 
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.TreeNodeDataModel
getParent, getParentKey, getUniqueKey, setParent
 

Field Detail

keepRows

private boolean keepRows
This flag directs the node 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

VirtualTreeGroupDataModel

public VirtualTreeGroupDataModel()
Constructor


VirtualTreeGroupDataModel

public VirtualTreeGroupDataModel(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 node


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

addChild

public void addChild(TreeNodeDataModel child)
Description copied from interface: TreeGroupDataModel
Adds a new node to the child list

Note: This method will also set the parent link of the new child node to this

Specified by:
addChild in interface TreeGroupDataModel
Parameters:
child - Child node
See Also:
TreeGroupDataModel.addChild(com.cc.framework.ui.model.TreeNodeDataModel)

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 node 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

getChild

public TreeNodeDataModel getChild(int index)
Description copied from interface: TreeGroupDataModel
Returns the node for the specified index

Specified by:
getChild in interface TreeGroupDataModel
Parameters:
index - The zero based index
Returns:
A tree node.
See Also:
TreeGroupDataModel.getChild(int)

getElementFromRowset

public TreeNodeDataModel 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: TreeGroupDataModel
Returns the number of children for this node

Specified by:
size in interface TreeGroupDataModel
Returns:
The number of child nodes.
See Also:
TreeGroupDataModel.size()

capacity

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

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

setSize

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

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 node.

Parameters:
i - new threshold value


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