Groovy Documentation

org.jdesktop.swingx.ws.yahoo.search
[Java] Interface PagedResultsList

org.jdesktop.swingx.ws.yahoo.search.PagedResultsList
  java.lang.Iterable
      java.util.Collection
          org.jdesktop.swingx.ws.yahoo.search.ResultsList
All Superinterfaces:
Iterable, Collection, ResultsList

public interface PagedResultsList
extends ResultsList

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
    }
 

Authors:
rbair


Method Summary
boolean firstPage()

int getNumPages()

Returns:
the number of total pages in this results list.

boolean gotoPage(int index)

boolean isHasNextPage()

Returns:
true if, according to getNumPages(), there is another page of data after that currently loaded in PagedResultsList.

boolean isHasPreviousPage()

Returns:
true if, according to getNumPages(), there is a previous page of data from that currently loaded in PagedResultsList.

boolean lastPage()

boolean nextPage()

boolean previousPage()

void refresh()

void setYahooSearch(YahooSearch search)

Sets the YahooSearch component to use for populating this PagedResultsList.

 
Methods inherited from interface ResultsList
getFirstResultPosition, getTotalResultsAvailable, getYahooSearch
 
Methods inherited from interface List
add, add, get, equals, hashCode, indexOf, clear, isEmpty, lastIndexOf, contains, addAll, addAll, size, toArray, toArray, iterator, remove, remove, set, listIterator, listIterator, subList, removeAll, containsAll, retainAll
 

Method Detail

firstPage

public 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.


getNumPages

public 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).


gotoPage

public 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.


isHasNextPage

public 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.


isHasPreviousPage

public 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.


lastPage

public 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.


nextPage

public 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

public 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.


refresh

public 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.

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


setYahooSearch

public 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.


 

Groovy Documentation