© 2005 BEA Systems, Inc.

com.beasys.commerce.ebusiness.util
Class DefaultScrollableModel

java.lang.Object
  extended bycom.beasys.commerce.ebusiness.util.DefaultScrollableModel
All Implemented Interfaces:
ScrollableModel, Serializable

public class DefaultScrollableModel
extends Object
implements ScrollableModel

This is the default implementation of the scrollable model interface. It should serve most requirements for a scrollable model.
It keeps all the primary keys used to get any value objects and caches a number of pages of value objects.
It uses a PageRetriever each time there is a page fault (i.e. a requested page is not cached in) to get the associated value objects.

See Also:
ScrollableModel, ScrollableModelPageRetriever, Serialized Form

Field Summary
protected  int cacheSize
           
protected  int count
           
protected  int currentFirstIndex
           
protected  int currentLastIndex
           
protected  Object[] currentPrimaryKeys
           
protected  Object[] currentValues
           
static int DEFAULT_NB_PAGES
           
static int DEFAULT_PAGE_SIZE
           
protected  int nbPages
           
protected  ScrollableModelPageRetriever pageRetriever
           
protected  int pageSize
           
protected  Object[] primaryKeys
           
protected  Class valueClass
           
 
Constructor Summary
DefaultScrollableModel(Object[] primaryKeys, int nbPages, int pageSize, ScrollableModelPageRetriever pageRetriever)
          This constructor needs the primary keys the scrollable model will manage, how to configure the pages, and which ScrollableModelPageRetriever to use on a page fault.
DefaultScrollableModel(Object[] primaryKeys, ScrollableModelPageRetriever pageRetriever)
          This constructor uses the default number of pages in the cache and the default number of items in a page.
 
Method Summary
 int getCount()
          gets the total number of elements managed by the Scrollable Model.
 Class getModelClass()
          All objects managed by the scrollable model are of the same class.
 int getNbPages()
          Gets the total number of pages over the scrollable model
 Object[] getPage(int pageIndex)
          Gets a page worth of Objects, given a page index.
 int getPageSize()
          gets the page size for an instance of a scrollable model i.e. '10' means 10 value objects are kept in one page.
 Object getValueAt(int valueIndex)
          Gets the value (hopefully a value object) based on the index the value
 void setValueAt(Serializable value, int valueIndex)
          This is an empty implementation of setValueAt It is here only to implement the ScrollableModel interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cacheSize

protected int cacheSize

count

protected int count

currentFirstIndex

protected int currentFirstIndex

currentLastIndex

protected int currentLastIndex

currentPrimaryKeys

protected Object[] currentPrimaryKeys

currentValues

protected Object[] currentValues

DEFAULT_NB_PAGES

public static final int DEFAULT_NB_PAGES
See Also:
Constant Field Values

DEFAULT_PAGE_SIZE

public static final int DEFAULT_PAGE_SIZE
See Also:
Constant Field Values

nbPages

protected int nbPages

pageRetriever

protected ScrollableModelPageRetriever pageRetriever

pageSize

protected int pageSize

primaryKeys

protected Object[] primaryKeys

valueClass

protected Class valueClass
Constructor Detail

DefaultScrollableModel

public DefaultScrollableModel(Object[] primaryKeys,
                              int nbPages,
                              int pageSize,
                              ScrollableModelPageRetriever pageRetriever)
This constructor needs the primary keys the scrollable model will manage, how to configure the pages, and which ScrollableModelPageRetriever to use on a page fault.


DefaultScrollableModel

public DefaultScrollableModel(Object[] primaryKeys,
                              ScrollableModelPageRetriever pageRetriever)
This constructor uses the default number of pages in the cache and the default number of items in a page.

Method Detail

getCount

public int getCount()
gets the total number of elements managed by the Scrollable Model.

Specified by:
getCount in interface ScrollableModel
Returns:
the count of all elements.

getModelClass

public Class getModelClass()
All objects managed by the scrollable model are of the same class. This method retrieves that class

Specified by:
getModelClass in interface ScrollableModel
Returns:
the Class of all objects managed by the scrollable model.

getNbPages

public int getNbPages()
Gets the total number of pages over the scrollable model

Specified by:
getNbPages in interface ScrollableModel
Returns:
the number of pages

getPage

public Object[] getPage(int pageIndex)
Gets a page worth of Objects, given a page index.

Specified by:
getPage in interface ScrollableModel
Returns:
an array of objects for that page.

getPageSize

public int getPageSize()
gets the page size for an instance of a scrollable model i.e. '10' means 10 value objects are kept in one page.

Specified by:
getPageSize in interface ScrollableModel
Returns:
the size of all pages

getValueAt

public Object getValueAt(int valueIndex)
Gets the value (hopefully a value object) based on the index the value

Specified by:
getValueAt in interface ScrollableModel
Returns:
the corresponding value as an Object

setValueAt

public void setValueAt(Serializable value,
                       int valueIndex)
This is an empty implementation of setValueAt It is here only to implement the ScrollableModel interface.

Specified by:
setValueAt in interface ScrollableModel

© 2005 BEA Systems, Inc.

Copyright © 2005 BEA Systems, Inc. All Rights Reserved