com.ibm.portal.um
Interface PagingIterator<T>


public interface PagingIterator<T>

The PagingIterator interface is returned by a paged search using com.ibm.portal.um.PumaLocator.
A paged search does not return all results at once but an iterator that partitions the results set into subsets (pages) of a specified size. This iterator also offers a random access mode.
As implementations of this iterator might choose to lazy-load pages, the get...Page methods throw PumaSystemException and PumaModelExcpetion to reflect problems during backend lookup.

Since:
7.0
See Also:
PumaLocator

Method Summary
 int getCurrentPageNumber()
          Returns the page number of the page that was recently requested or -1 if no page has been requested yet.
 java.util.List<T> getFirstPage(java.util.List<T> buffer)
          This method returns the first page of search results.
 java.util.List<T> getLastPage(java.util.List<T> buffer)
          This method returns the last page of search results.
 java.util.List<T> getNextPage(java.util.List<T> buffer)
          This method returns the next page of search results if available.
 int getNumberOfPages()
          Returns the number of pages that were found by the search request.
 int getNumberOfTotalResults()
          Returns the size of the complete result set.
 java.util.List<T> getPage(java.util.List<T> buffer, int pageNumber)
          This method returns the page with the given number if available
 java.util.List<T> getPreviousPage(java.util.List<T> buffer)
          This method returns the previous page of search results if available.
 boolean hasNextPage()
          Returns true if there is a next page available.
 boolean hasPreviousPage()
          Returns true if there is a previous page available.
 

Method Detail

getCurrentPageNumber

int getCurrentPageNumber()
Returns the page number of the page that was recently requested or -1 if no page has been requested yet.

Returns:
the number of the page requested recently

getNumberOfPages

int getNumberOfPages()
Returns the number of pages that were found by the search request. Will be at least 1, even if getNumberOfTotalResults() returns 0. In that case the first page will not contain any entries.

Returns:
the number of pages that are available

getNumberOfTotalResults

int getNumberOfTotalResults()
Returns the size of the complete result set. If this number is higher than the page size, the result set is split up into more than one page.

Returns:
the size of the complete result set.

hasNextPage

boolean hasNextPage()
Returns true if there is a next page available. (In other words, returns true if getNextPage would return an element rather than throwing an exception.)

Returns:
true if a next page is available

getNextPage

java.util.List<T> getNextPage(java.util.List<T> buffer)
                              throws PumaModelException,
                                     PumaSystemException
This method returns the next page of search results if available. The first invocation of this method on the object will always return a page, it might be empty. Shortcut for getPage(buffer, getCurrentPageNumber()+1)

Parameters:
buffer - - a modifiable list that will be cleared and filled or null
Returns:
a list of search results representing the next page
Throws:
PumaSystemException - if lazy loading of a page fails
PumaModelException - if the requeted page is not available or if lazy loading of a page fails

hasPreviousPage

boolean hasPreviousPage()
Returns true if there is a previous page available. (In other words, returns true if getPreviousPage would return an element rather than throwing an exception.)

Returns:
true if a previous page is available

getPreviousPage

java.util.List<T> getPreviousPage(java.util.List<T> buffer)
                                  throws PumaModelException,
                                         PumaSystemException
This method returns the previous page of search results if available. Shortcut for getPage(buffer, getCurrentPageNumber()-1)

Parameters:
buffer - - a modifiable list that will be cleared and filled or null
Returns:
a list of search results representing the previous page
Throws:
PumaSystemException - if lazy loading of a page fails
PumaModelException - if the requeted page is not available or if lazy loading of a page fails

getFirstPage

java.util.List<T> getFirstPage(java.util.List<T> buffer)
                               throws PumaModelException,
                                      PumaSystemException
This method returns the first page of search results.

Parameters:
buffer - - a modifiable list that will be cleared and filled or null
Returns:
a list of search results representing the first page
Throws:
PumaSystemException - if lazy loading of a page fails
PumaModelException - if the requeted page is not available or if lazy loading of a page fails

getLastPage

java.util.List<T> getLastPage(java.util.List<T> buffer)
                              throws PumaModelException,
                                     PumaSystemException
This method returns the last page of search results.

Parameters:
buffer - - a modifiable list that will be cleared and filled or null
Throws:
PumaSystemException - if lazy loading of a page fails
PumaModelException - if the requeted page is not available or if lazy loading of a page fails

getPage

java.util.List<T> getPage(java.util.List<T> buffer,
                          int pageNumber)
                          throws PumaModelException,
                                 PumaSystemException
This method returns the page with the given number if available

Parameters:
buffer - - a modifiable list that will be cleared and filled or null
Returns:
a list of search results representing the requested page
Throws:
PumaSystemException - if lazy loading of a page fails
PumaModelException - if the requeted page is not available or if lazy loading of a page fails