# com.beasys.commerce.ebusiness.util
DefaultScrollableModel Class

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.

Related Topics

``ScrollableModel``
``ScrollableModelPageRetriever``

Hierarchy
  `Object`
  `DefaultScrollableModel`

All Implemented Interfaces
  `ScrollableModel`, `Serializable`

## Field Summary

`protected int` | `cacheSize` int
`protected int` | `count` int
`protected int` | `currentFirstIndex` int
`protected int` | `currentLastIndex` int
`protected `Object`` | `currentPrimaryKeys` Object
`protected `Object`` | `currentValues` Object
`public static final int` | `DEFAULT_NB_PAGES` int
`public static final int` | `DEFAULT_PAGE_SIZE` int
`protected int` | `nbPages` int
`protected `ScrollableModelPageRetriever`` | `pageRetriever` ScrollableModelPageRetriever
`protected int` | `pageSize` int
`protected `Object`` | `primaryKeys` Object
`protected `Class`` | `valueClass` Class

## Constructor Summary

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

## Method Summary

`public synchronized int` | `getCount`() gets the total number of elements managed by the Scrollable Model.
`public synchronized `Class`` | `getModelClass`() All objects managed by the scrollable model are of the same class.
`public synchronized int` | `getNbPages`() Gets the total number of pages over the scrollable model
`public synchronized `Object`[]` | `getPage`(int pageIndex) Gets a page worth of Objects, given a page index.
`public synchronized 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.
`public synchronized `Object`` | `getValueAt`(int valueIndex) Gets the value (hopefully a value object) based on the index the value
`public synchronized void` | `setValueAt`(`Serializable` value, int valueIndex) This is an empty implementation of setValueAt It is here only to implement the ScrollableModel interface.

Methods from class `java.lang.`Object``
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods from interface `com.beasys.commerce.ebusiness.util.`ScrollableModel``
``getCount`, `getModelClass`, `getNbPages`, `getPage`, `getPageSize`, `getValueAt`, `setValueAt``

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

### DEFAULT_PAGE_SIZE

    public static final int DEFAULT_PAGE_SIZE

### 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,
                                  ScrollableModelPageRetriever pageRetriever)

  This constructor uses the default number of pages in the cache and the default number of items in a page.

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

## Method Detail

### getCount() Method

    public synchronized int getCount()

gets the total number of elements managed by the Scrollable Model.

#### Returns

the count of all elements.

### getModelClass() Method

    public synchronized Class getModelClass()

All objects managed by the scrollable model are of the same class. This method retrieves that class

#### Returns

the Class of all objects managed by the scrollable model.

### getNbPages() Method

    public synchronized int getNbPages()

Gets the total number of pages over the scrollable model

#### Returns

the number of pages

### getPage(int) Method

    public synchronized Object[] getPage(int pageIndex)

Gets a page worth of Objects, given a page index.

#### Parameters

pageIndex
  the index in the list of pages

#### Returns

an array of objects for that page.

### getPageSize() Method

    public synchronized 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.

#### Returns

the size of all pages

### getValueAt(int) Method

    public synchronized Object getValueAt(int valueIndex)

Gets the value (hopefully a value object) based on the index the value

#### Parameters

valueIndex
  the index for the value to retrieve

#### Returns

the corresponding value as an Object

### setValueAt(Serializable, int) Method

    public synchronized void setValueAt(Serializable value,
                                        int valueIndex)

This is an empty implementation of setValueAt It is here only to implement the ScrollableModel interface.

#### Parameters

value
  the 'value object' at a location in the list

valueIndex
  the location of the value object in the list