org.jdesktop.swingx.ws.yahoo.search
Interface PagedResultsList<E>

All Superinterfaces:
Collection<E>, Iterable<E>, List<E>, ResultsList<E>
All Known Implementing Classes:
PagedResultsArrayList

public interface PagedResultsList<E>
extends ResultsList<E>

A ResultsList that pages through all of the results. This class contains a set of methods that allow you to navigate through all of the pages in a set of results. It only presents a single page of results at a time, which are available through the methods in the java.util.List interface (such as the get(int) method).

Here is some example usage:


    PagedResultsList results = new PagedResultsArrayList();
    results.setYahooSearch(yahooWebSearch);
    results.refresh();
    System.out.println(results.getNumPages());
    ...

    if (results.hasNextPage()) {
        results.nextPage();
        System.out.println(results.size()); // number of results in this page
        System.out.println(results.get(0)); // fetches and prints the first result on this page
    }
 


Method Summary
 boolean firstPage()
          Reloads this PagedResultsList by searching the YahooSearch component for the first page of results.
 int getNumPages()
           
 boolean gotoPage(int index)
          Reloads this PagedResultsList by searching the YahooSearch component for the given page of results.
 boolean isHasNextPage()
           
 boolean isHasPreviousPage()
           
 boolean lastPage()
          Reloads this PagedResultsList by searching the YahooSearch component for the last page of results.
 boolean nextPage()
          Reloads this PagedResultsList by searching the YahooSearch component for the next page of results.
 boolean previousPage()
          Reloads this PagedResultsList by searching the YahooSearch component for the previous page of results.
 void refresh()
          Reloads this PagedResultsList by searching the YahooSearch component for the current page of results.
 void setYahooSearch(YahooSearch search)
          Sets the YahooSearch component to use for populating this PagedResultsList.
 
Methods inherited from interface org.jdesktop.swingx.ws.yahoo.search.ResultsList
getFirstResultPosition, getTotalResultsAvailable, getYahooSearch
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
 

Method Detail

getNumPages

int getNumPages()
Returns:
the number of total pages in this results list. This value can change whenever refresh() is called, or whenever the page index is changed via one of the page modification methods (firstPage, lastPage, etc).

nextPage

boolean nextPage()

Reloads this PagedResultsList by searching the YahooSearch component for the next page of results. If hasNextPage returns false, this method does nothing and returns false. If the YahooSearch component is not set, this method returns false.

This method blocks, and should only be called from org.jdesktop.swingx.ws.BackgroundWorker or SwingWorker or another background threading library.

Returns:
true upon a successful loading of the next page.

previousPage

boolean previousPage()

Reloads this PagedResultsList by searching the YahooSearch component for the previous page of results. If hasPrevPage returns false, this method does nothing and returns false. If the YahooSearch component is not set, this method returns false.

This method blocks, and should only be called from org.jdesktop.swingx.ws.BackgroundWorker or SwingWorker or another background threading library.

Returns:
true upon a successful loading of the previous page.

firstPage

boolean firstPage()

Reloads this PagedResultsList by searching the YahooSearch component for the first page of results. If the YahooSearch component is not set, this method returns false.

This method blocks, and should only be called from org.jdesktop.swingx.ws.BackgroundWorker or SwingWorker or another background threading library.

Returns:
true upon a successful loading of the first page.

lastPage

boolean lastPage()

Reloads this PagedResultsList by searching the YahooSearch component for the last page of results. If the YahooSearch component is not set, this method returns false.

This method blocks, and should only be called from org.jdesktop.swingx.ws.BackgroundWorker or SwingWorker or another background threading library.

Returns:
true upon a successful loading of the last page.

gotoPage

boolean gotoPage(int index)

Reloads this PagedResultsList by searching the YahooSearch component for the given page of results. The index is 0 based. If the YahooSearch component is not set, this method returns false.

This method blocks, and should only be called from org.jdesktop.swingx.ws.BackgroundWorker or SwingWorker or another background threading library.

Parameters:
index - a 0 based index of the page to load. If index > getNumPages(), then an IllegalArgumentException is thrown. Likewise if index < 0.
Returns:
true upon a successful loading of the given page.

isHasPreviousPage

boolean isHasPreviousPage()
Returns:
true if, according to getNumPages(), there is a previous page of data from that currently loaded in PagedResultsList. If the YahooSearch component is not set, this method returns false.

isHasNextPage

boolean isHasNextPage()
Returns:
true if, according to getNumPages(), there is another page of data after that currently loaded in PagedResultsList. If the YahooSearch component is not set, this method returns false.

refresh

void refresh()

Reloads this PagedResultsList by searching the YahooSearch component for the current page of results. If the YahooSearch component is not set, this method returns false.

This method blocks, and should only be called from org.jdesktop.swingx.ws.BackgroundWorker or SwingWorker or another background threading library.


setYahooSearch

void setYahooSearch(YahooSearch search)
Sets the YahooSearch component to use for populating this PagedResultsList. Setting this property while this list is populated with results will not clear those results.

Parameters:
search - the YahooSearch component to use for populating this PagedResultsList. This may be null.