Package jetbrains.buildServer.util
Class Pager
- java.lang.Object
-
- jetbrains.buildServer.util.Pager
-
public class Pager extends Object
- Author:
- Kir This class is the model for Pager, i.e. it maintains current page and allows to get records for the current page.
-
-
Field Summary
Fields Modifier and Type Field Description static int
LR_PAGE_COUNT
-
Constructor Summary
Constructors Constructor Description Pager(int recordsPerPage)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getCurrentPage()
Page numbers are started with 1<T> List<T>
getCurrentPageData(List<T> data)
int
getFirstIndex()
int
getLastIndex()
int
getPageCount()
int
getRecordsPerPage()
int
getTotalRecords()
int[]
getVisiblePages()
boolean
isLastPage()
boolean
isNextPageExists()
boolean
isPreviousPageExists()
boolean
isUnknownNumberOfRecords()
void
setCurrentPage(int page)
Page numbers are started with 1int
setCurrentPageFromRecord(int recordIdx)
Computes page containing record with specified index and sets this page as current.void
setNumberOfRecords(int totalRecords)
Set total number of records in collection to be pagedvoid
setRecordsPerPage(int recordsPerPage)
Set number of records per page.void
setUnknownNumberOfRecords(boolean unknownNumberOfRecords)
Set to true if current total number of records is smaller than the actual number of records
-
-
-
Field Detail
-
LR_PAGE_COUNT
public static final int LR_PAGE_COUNT
- See Also:
- Constant Field Values
-
-
Method Detail
-
setRecordsPerPage
public void setRecordsPerPage(int recordsPerPage)
Set number of records per page. Value -1 means unlimited number of records- Parameters:
recordsPerPage
- see above
-
setNumberOfRecords
public void setNumberOfRecords(int totalRecords)
Set total number of records in collection to be paged- Parameters:
totalRecords
- total number of records
-
setCurrentPage
public void setCurrentPage(int page)
Page numbers are started with 1- Parameters:
page
- current page, starting from 1
-
setCurrentPageFromRecord
public int setCurrentPageFromRecord(int recordIdx)
Computes page containing record with specified index and sets this page as current.- Parameters:
recordIdx
- index of a record, starting from zero- Returns:
- index of the record on the selected page
-
getCurrentPage
public int getCurrentPage()
Page numbers are started with 1- Returns:
- current page number
-
isLastPage
public boolean isLastPage()
-
getRecordsPerPage
public int getRecordsPerPage()
- Returns:
- number of records per page
-
getTotalRecords
public int getTotalRecords()
- Returns:
- total number of records per page
-
getCurrentPageData
public <T> List<T> getCurrentPageData(List<T> data)
- Parameters:
data
- original collection of records (all of them)- Returns:
- sublist of the data with information for the current page
-
getLastIndex
public int getLastIndex()
-
getFirstIndex
public int getFirstIndex()
-
getPageCount
public int getPageCount()
- Returns:
- total number of pages, according to total number of records and records per page
-
isPreviousPageExists
public boolean isPreviousPageExists()
- Returns:
- true if there is a previous page
-
isNextPageExists
public boolean isNextPageExists()
- Returns:
- true if there is a next page
-
getVisiblePages
public int[] getVisiblePages()
- Returns:
- numbers of visible pages (helper method on Web UI)
-
isUnknownNumberOfRecords
public boolean isUnknownNumberOfRecords()
- Returns:
- true if actual total number of records is bigger than the total number of records set to this pager
-
setUnknownNumberOfRecords
public void setUnknownNumberOfRecords(boolean unknownNumberOfRecords)
Set to true if current total number of records is smaller than the actual number of records- Parameters:
unknownNumberOfRecords
- true in case of a pager with open interval and false otherwise (default)
-
-