R
- Class associated with a row in tableC
- collection type for one pagepublic class PaginatedSelector<R,C>
extends java.lang.Object
implements java.lang.AutoCloseable
SelectOperation
. The
same select operation is used for all pages so that only one PreparedStatement
is created
for all pages.Modifier | Constructor and Description |
---|---|
protected |
PaginatedSelector(int pageSize,
boolean scrollSensitive)
Constructs for a page size and scroll sensitivity.
|
|
PaginatedSelector(int pageSize,
SelectOperation<R,C> selectOperation)
Constructs for a page size and select operation.
|
|
PaginatedSelector(int pageSize,
SelectOperation<R,C> selectOperation,
boolean scrollSensitive)
Constructs for a page size, select operation, and scroll sensitivity.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the select operation with
ScalarSelectOperation.close() . |
protected void |
confirmExecuted() |
void |
execute()
Executes the select operation and positions to the first page.
|
int |
getPageNumber()
|
int |
getPageSize()
Gets the page size that was specified in the constructor.
|
protected void |
init(SelectOperation<R,C> selectOperation) |
boolean |
isScrollSensitive()
Gets the result set scroll sensitivity that was specified in the constructor.
|
void |
nextPage()
Move result set cursor to
getPageNumber() + 1 |
void |
previousPage()
Move result set cursor to
getPageNumber() - 1 |
C |
selectPage()
Selects rows for current page.
|
R |
selectRow()
Selects next row from the current page.
|
void |
setPageNumber(int pageNumber)
Positions result set cursor to a specific page.
|
protected void |
topOfPage()
Positions result set cursor to the top of the page.
|
public PaginatedSelector(int pageSize, SelectOperation<R,C> selectOperation)
pageSize
- rows per pageselectOperation
- the operation to select rowspublic PaginatedSelector(int pageSize, SelectOperation<R,C> selectOperation, boolean scrollSensitive)
pageSize
- rows per pageselectOperation
- the operation to select rowsscrollSensitive
- true to use result set type of ResultSet.TYPE_SCROLL_SENSITIVE
,
false to use ResultSet.TYPE_SCROLL_INSENSITIVE
protected PaginatedSelector(int pageSize, boolean scrollSensitive)
init(SelectOperation)
. This constructor is for subclasses that initialize
the select operation in a specialized way.pageSize
- rows per pagescrollSensitive
- true to use result set type of ResultSet.TYPE_SCROLL_SENSITIVE
,
false to use ResultSet.TYPE_SCROLL_INSENSITIVE
protected void init(SelectOperation<R,C> selectOperation)
public void execute() throws SelectorException
SelectorException
- if errorScalarSelectOperation.execute()
protected void confirmExecuted() throws SelectorException
SelectorException
public int getPageSize()
public boolean isScrollSensitive()
Connection.prepareStatement(String, int, int)
public int getPageNumber()
selectPage()
, selectRow()
public void setPageNumber(int pageNumber) throws SelectorException
selectPage()
will be empty and selectRow()
will return null.pageNumber
- position to specific page, pages less than 1 will cause an exceptionSelectorException
- if errorScalarSelectOperation.positionAbsolute(int)
public void nextPage() throws SelectorException
getPageNumber()
+ 1SelectorException
- if errorpublic void previousPage() throws SelectorException
getPageNumber()
- 1SelectorException
- if errorpublic C selectPage() throws SelectorException
SelectorException
- if errorpublic R selectRow() throws SelectorException
setPageNumber(int)
prior
to selectRow()
to start at top of page. Use this method instead of selectPage()
if you would like to read one row at-a-time rather than the whole page.SelectorException
- if errorpublic void close() throws SelectorException
ScalarSelectOperation.close()
.close
in interface java.lang.AutoCloseable
SelectorException
protected void topOfPage() throws SelectorException
SelectorException
- if error