com.taleo.integration.client.customstep.paging
Class PagingManager

java.lang.Object
  extended by com.taleo.integration.client.customstep.paging.PagingManager

public class PagingManager
extends java.lang.Object

Manage the paging state.

Reads and writes the paging state (page index and record count) on disk. Also stores paging parameters (paging size, decrease factor, current run date), because those cannot change until the whole paging cycle is complete.

Author:
Romain Guay - Taleo Corporation

Field Summary
static java.lang.String PIPELINE_KEY
          Key for the PagingManager in the pipeline.
 
Constructor Summary
PagingManager(java.io.File file, int pagingSize, int decreaseFactor, java.util.Date lastRunDate, java.util.Date currentRunDate)
          Constructor with the file to read/write the paging state, the paging size, the decrease factor, the last run date and the current run date.
 
Method Summary
 void addNewPage()
          Add a new page.
 void delete()
          Delete the paging file.
 int getAdjustedPagingSize()
          Get the paging size adjusted for the decrease factor.
 int getCurrentPageIndex()
          Get the current page index (1 based).
 int getCurrentRecordCount()
          Get the current record count (corresponding to the current page index).
 int getPagingSize()
          Get the paging size.
 boolean isComplete()
          Indicate if paging is complete.
 boolean isNew()
          Indicate if paging is new.
 void save()
          Save the current state in the paging file.
 void setCurrentRecordCount(int currentRecordCount)
          Set the current record count.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PIPELINE_KEY

public static final java.lang.String PIPELINE_KEY
Key for the PagingManager in the pipeline.

See Also:
Constant Field Values
Constructor Detail

PagingManager

public PagingManager(java.io.File file,
                     int pagingSize,
                     int decreaseFactor,
                     java.util.Date lastRunDate,
                     java.util.Date currentRunDate)
              throws java.io.IOException
Constructor with the file to read/write the paging state, the paging size, the decrease factor, the last run date and the current run date.

If paging size, decrease factor, last run date or current run date have changed since the last cycle, while paging was not complete, throw an exception because paging will be inconsistent.

Parameters:
file - The file to store and retrieve the paging state.
pagingSize - The paging size.
decreaseFactor - The decrease factor.
lastRunDate - The last run date, may be null.
currentRunDate - The current run date, may be null.
Throws:
java.io.IOException
Method Detail

addNewPage

public void addNewPage()
Add a new page.


getPagingSize

public int getPagingSize()
Get the paging size.

Returns:

getAdjustedPagingSize

public int getAdjustedPagingSize()
Get the paging size adjusted for the decrease factor.

Returns:

getCurrentPageIndex

public int getCurrentPageIndex()
Get the current page index (1 based).

Equals 0 if there is no current page.

Returns:

getCurrentRecordCount

public int getCurrentRecordCount()
Get the current record count (corresponding to the current page index).

Equals -1 if not set for the current page.

Returns:

setCurrentRecordCount

public void setCurrentRecordCount(int currentRecordCount)
Set the current record count.

Parameters:
currentRecordCount -

isNew

public boolean isNew()
Indicate if paging is new.

Returns:

isComplete

public boolean isComplete()
Indicate if paging is complete.

Returns:

save

public void save()
          throws java.io.IOException
Save the current state in the paging file.

Throws:
java.io.IOException

delete

public void delete()
            throws java.io.IOException
Delete the paging file.

Throws:
java.io.IOException