com.vaadin.client.data
Class CacheStrategy.AbstractBasicSymmetricalCacheStrategy

java.lang.Object
  extended by com.vaadin.client.data.CacheStrategy.AbstractBasicSymmetricalCacheStrategy
All Implemented Interfaces:
CacheStrategy
Direct Known Subclasses:
CacheStrategy.DefaultCacheStrategy
Enclosing interface:
CacheStrategy

public abstract static class CacheStrategy.AbstractBasicSymmetricalCacheStrategy
extends java.lang.Object
implements CacheStrategy

A helper class for creating a simple symmetric cache strategy that uses the same logic for both rows before and after the currently cached range.

This simple approach rules out more advanced heuristics that would take the current scrolling direction or past scrolling behavior into account.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.vaadin.client.data.CacheStrategy
CacheStrategy.AbstractBasicSymmetricalCacheStrategy, CacheStrategy.DefaultCacheStrategy
 
Constructor Summary
CacheStrategy.AbstractBasicSymmetricalCacheStrategy()
           
 
Method Summary
 com.vaadin.shared.ui.grid.Range getMaxCacheRange(com.vaadin.shared.ui.grid.Range displayedRange, com.vaadin.shared.ui.grid.Range cachedRange, com.vaadin.shared.ui.grid.Range estimatedAvailableRange)
          Gets the maximum row range that should be cached.
abstract  int getMaximumCacheSize(int pageSize)
          Gets the maximum number of extra items to cache in one direction.
 com.vaadin.shared.ui.grid.Range getMinCacheRange(com.vaadin.shared.ui.grid.Range displayedRange, com.vaadin.shared.ui.grid.Range cachedRange, com.vaadin.shared.ui.grid.Range estimatedAvailableRange)
          Gets the minimum row range that should be cached.
abstract  int getMinimumCacheSize(int pageSize)
          Gets the the minimum number of extra items to cache in one direction.
 void onDataArrive(double roundTripTime, int rowCount)
          Called whenever data requested by the data source has arrived.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheStrategy.AbstractBasicSymmetricalCacheStrategy

public CacheStrategy.AbstractBasicSymmetricalCacheStrategy()
Method Detail

onDataArrive

public void onDataArrive(double roundTripTime,
                         int rowCount)
Description copied from interface: CacheStrategy
Called whenever data requested by the data source has arrived. This information can e.g. be used for measuring how long it takes to fetch different number of rows from the server.

A cache strategy implementation cannot use this information to keep track of which items are in the cache since the data source might discard items without notifying the cache strategy.

Specified by:
onDataArrive in interface CacheStrategy
Parameters:
roundTripTime - the total number of milliseconds elapsed from requesting the data until the response was passed to the data source
rowCount - the number of received rows

getMinCacheRange

public com.vaadin.shared.ui.grid.Range getMinCacheRange(com.vaadin.shared.ui.grid.Range displayedRange,
                                                        com.vaadin.shared.ui.grid.Range cachedRange,
                                                        com.vaadin.shared.ui.grid.Range estimatedAvailableRange)
Description copied from interface: CacheStrategy
Gets the minimum row range that should be cached. The data source will fetch new data if the currently cached range does not fill the entire minimum cache range.

Specified by:
getMinCacheRange in interface CacheStrategy
Parameters:
displayedRange - the range of currently displayed rows
cachedRange - the range of currently cached rows
estimatedAvailableRange - the estimated range of rows available for the data source
Returns:
the minimum range of rows that should be cached, should at least include the displayed range and should not exceed the total estimated available range

getMaxCacheRange

public com.vaadin.shared.ui.grid.Range getMaxCacheRange(com.vaadin.shared.ui.grid.Range displayedRange,
                                                        com.vaadin.shared.ui.grid.Range cachedRange,
                                                        com.vaadin.shared.ui.grid.Range estimatedAvailableRange)
Description copied from interface: CacheStrategy
Gets the maximum row range that should be cached. The data source will discard cached rows that are outside the maximum range.

Specified by:
getMaxCacheRange in interface CacheStrategy
Parameters:
displayedRange - the range of currently displayed rows
cachedRange - the range of currently cached rows
estimatedAvailableRange - the estimated range of rows available for the data source
Returns:
the maximum range of rows that should be cached, should at least include the displayed range and should not exceed the total estimated available range

getMaximumCacheSize

public abstract int getMaximumCacheSize(int pageSize)
Gets the maximum number of extra items to cache in one direction.

Parameters:
pageSize - the current number of items used at once
Returns:
maximum of items to cache

getMinimumCacheSize

public abstract int getMinimumCacheSize(int pageSize)
Gets the the minimum number of extra items to cache in one direction.

Parameters:
pageSize - the current number of items used at once
Returns:
minimum number of items to cache


Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.