|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jdesktop.beans.AbstractBean
org.jdesktop.swingx.ws.yahoo.search.PagedResultsArrayList<E>
public class PagedResultsArrayList<E>
A non visual JavaBean that represents the results of a Yahoo! search. Unlike
ResultsList which only contains the results of a single "page" of
search results, PagedResultsArrayList allows you to step through all of the
results returned from a search.
Sample usage:
YahooWebSearch yahoo = new YahooWebSearch();
yahoo.appId = "myappidxxx(get one from yahoo)";
yahoo.query = "world cup 2006 Italy";
PagedResultsArrayList results = new
PagedResultsArrayList();
results.setYahooSearch(yahoo);
results.refresh();
System.out.println("NumPages: " + results.getNumPages());
System.out.println("NumResults: " + results.getTotalResultsAvailable());
int count = 1;
while (count < 300 && results.hasNextPage()) {
for (int i=0; i
| Constructor Summary | |
|---|---|
PagedResultsArrayList()
Creates a new instance of PagedResultsArrayList |
|
| Method Summary | ||
|---|---|---|
boolean |
add(E e)
Appends the specified element to the end of this list (optional operation). |
|
void |
add(int index,
E element)
Inserts the specified element at the specified position in this list (optional operation). |
|
boolean |
addAll(Collection<? extends E> c)
Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation). |
|
boolean |
addAll(int index,
Collection<? extends E> c)
Inserts all of the elements in the specified collection into this list at the specified position (optional operation). |
|
void |
clear()
Removes all of the elements from this list (optional operation). |
|
boolean |
contains(Object o)
Returns true if this list contains the specified element. |
|
boolean |
containsAll(Collection<?> c)
Returns true if this list contains all of the elements of the specified collection. |
|
boolean |
equals(Object o)
Indicates whether some other object is "equal to" this one. |
|
boolean |
firstPage()
Reloads this PagedResultsList by searching the YahooSearch component for the first page of results. |
|
E |
get(int index)
Returns the element at the specified position in this list. |
|
int |
getCurrentPageIndex()
|
|
int |
getFirstResultPosition()
|
|
int |
getNumPages()
|
|
int |
getResultsPerPage()
|
|
int |
getTotalResultsAvailable()
|
|
YahooSearch |
getYahooSearch()
|
|
boolean |
gotoPage(int index)
Reloads this PagedResultsList by searching the YahooSearch component for the given page of results. |
|
int |
hashCode()
Returns a hash code value for the object. |
|
int |
indexOf(Object o)
Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element. |
|
boolean |
isEmpty()
Returns true if this list contains no elements. |
|
boolean |
isHasNextPage()
|
|
boolean |
isHasPreviousPage()
|
|
Iterator<E> |
iterator()
Returns an iterator over the elements in this list in proper sequence. |
|
int |
lastIndexOf(Object o)
Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element. |
|
boolean |
lastPage()
Reloads this PagedResultsList by searching the YahooSearch component for the last page of results. |
|
ListIterator<E> |
listIterator()
Returns a list iterator of the elements in this list (in proper sequence). |
|
ListIterator<E> |
listIterator(int index)
Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list. |
|
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. |
|
E |
remove(int index)
Removes the element at the specified position in this list (optional operation). |
|
boolean |
remove(Object o)
Removes the first occurrence in this list of the specified element (optional operation). |
|
boolean |
removeAll(Collection<?> c)
Removes from this list all the elements that are contained in the specified collection (optional operation). |
|
boolean |
retainAll(Collection<?> c)
Retains only the elements in this list that are contained in the specified collection (optional operation). |
|
E |
set(int index,
E element)
Replaces the element at the specified position in this list with the specified element (optional operation). |
|
void |
setResultsPerPage(int value)
|
|
void |
setYahooSearch(YahooSearch search)
Sets the YahooSearch component to use for populating this PagedResultsList. |
|
int |
size()
Returns the number of elements in this list. |
|
List<E> |
subList(int fromIndex,
int toIndex)
Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. |
|
Object[] |
toArray()
Returns an array containing all of the elements in this list in proper sequence. |
|
|
toArray(T[] a)
Returns an array containing all of the elements in this list in proper sequence; the runtime type of the returned array is that of the specified array. |
|
| Methods inherited from class org.jdesktop.beans.AbstractBean |
|---|
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clone, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PagedResultsArrayList()
| Method Detail |
|---|
public int getNumPages()
getNumPages in interface PagedResultsList<E>public boolean nextPage()
PagedResultsListReloads 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.
nextPage in interface PagedResultsList<E>public boolean previousPage()
PagedResultsListReloads 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.
previousPage in interface PagedResultsList<E>public boolean firstPage()
PagedResultsListReloads 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.
firstPage in interface PagedResultsList<E>public boolean lastPage()
PagedResultsListReloads 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.
lastPage in interface PagedResultsList<E>public boolean gotoPage(int index)
PagedResultsListReloads 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.
gotoPage in interface PagedResultsList<E>index - a 0 based index of the page to load. If index > getNumPages(), then
an IllegalArgumentException is thrown. Likewise if index < 0.
public boolean isHasPreviousPage()
isHasPreviousPage in interface PagedResultsList<E>public boolean isHasNextPage()
isHasNextPage in interface PagedResultsList<E>public void refresh()
PagedResultsListReloads 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.
refresh in interface PagedResultsList<E>public final void setYahooSearch(YahooSearch search)
PagedResultsList
setYahooSearch in interface PagedResultsList<E>search - the YahooSearch component to use for populating this PagedResultsList.
This may be null.public final YahooSearch getYahooSearch()
getYahooSearch in interface ResultsList<E>YahooSearch that was used to produce this ResultsList. May
be null.public final int getTotalResultsAvailable()
getTotalResultsAvailable in interface ResultsList<E>public final int getFirstResultPosition()
getFirstResultPosition in interface ResultsList<E>public final int getCurrentPageIndex()
public final void setResultsPerPage(int value)
public final int getResultsPerPage()
public int size()
java.util.List
size in interface Collection<E>size in interface List<E>public boolean isEmpty()
java.util.List
isEmpty in interface Collection<E>isEmpty in interface List<E>public boolean contains(Object o)
java.util.List
contains in interface Collection<E>contains in interface List<E>o - element whose presence in this list is to be tested.
public Iterator<E> iterator()
java.util.List
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in interface List<E>public Object[] toArray()
java.util.List
toArray in interface Collection<E>toArray in interface List<E>Arrays.asList(Object[])public <T> T[] toArray(T[] a)
java.util.List
toArray in interface Collection<E>toArray in interface List<E>a - the array into which the elements of this list are to
be stored, if it is big enough; otherwise, a new array of the
same runtime type is allocated for this purpose.
public boolean add(E e)
java.util.ListLists that support this operation may place limitations on what elements may be added to this list. In particular, some lists will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. List classes should clearly specify in their documentation any restrictions on what elements may be added.
add in interface Collection<E>add in interface List<E>e - element to be appended to this list.
public boolean remove(Object o)
java.util.List
remove in interface Collection<E>remove in interface List<E>o - element to be removed from this list, if present.
public boolean containsAll(Collection<?> c)
java.util.List
containsAll in interface Collection<E>containsAll in interface List<E>c - collection to be checked for containment in this list.
List.contains(Object)public boolean addAll(Collection<? extends E> c)
java.util.List
addAll in interface Collection<E>addAll in interface List<E>c - collection whose elements are to be added to this list.
List.add(Object)
public boolean addAll(int index,
Collection<? extends E> c)
java.util.List
addAll in interface List<E>index - index at which to insert first element from the specified
collection.c - elements to be inserted into this list.
public boolean removeAll(Collection<?> c)
java.util.List
removeAll in interface Collection<E>removeAll in interface List<E>c - collection that defines which elements will be removed from
this list.
List.remove(Object),
List.contains(Object)public boolean retainAll(Collection<?> c)
java.util.List
retainAll in interface Collection<E>retainAll in interface List<E>c - collection that defines which elements this set will retain.
List.remove(Object),
List.contains(Object)public void clear()
java.util.List
clear in interface Collection<E>clear in interface List<E>public boolean equals(Object o)
java.lang.Object
The equals method implements an equivalence relation
on non-null object references:
x, x.equals(x) should return
true.
x and y, x.equals(y)
should return true if and only if
y.equals(x) returns true.
x, y, and z, if
x.equals(y) returns true and
y.equals(z) returns true, then
x.equals(z) should return true.
x and y, multiple invocations of
x.equals(y) consistently return true
or consistently return false, provided no
information used in equals comparisons on the
objects is modified.
x,
x.equals(null) should return false.
The equals method for class Object implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x and
y, this method returns true if and only
if x and y refer to the same object
(x == y has the value true).
Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.
equals in interface Collection<E>equals in interface List<E>equals in class Objecto - the reference object with which to compare.
true if this object is the same as the obj
argument; false otherwise.Object.hashCode(),
Hashtablepublic int hashCode()
java.lang.Objectjava.util.Hashtable.
The general contract of hashCode is:
hashCode method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hashtables.
As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)
hashCode in interface Collection<E>hashCode in interface List<E>hashCode in class ObjectObject.equals(java.lang.Object),
Hashtablepublic E get(int index)
java.util.List
get in interface List<E>index - index of element to return.
public E set(int index,
E element)
java.util.List
set in interface List<E>index - index of element to replace.element - element to be stored at the specified position.
public void add(int index,
E element)
java.util.List
add in interface List<E>index - index at which the specified element is to be inserted.element - element to be inserted.public E remove(int index)
java.util.List
remove in interface List<E>index - the index of the element to removed.
public int indexOf(Object o)
java.util.List
indexOf in interface List<E>o - element to search for.
public int lastIndexOf(Object o)
java.util.List
lastIndexOf in interface List<E>o - element to search for.
public ListIterator<E> listIterator()
java.util.List
listIterator in interface List<E>public ListIterator<E> listIterator(int index)
java.util.List
listIterator in interface List<E>index - index of first element to be returned from the
list iterator (by a call to the next method).
public List<E> subList(int fromIndex,
int toIndex)
java.util.ListThis method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list:
list.subList(from, to).clear();
Similar idioms may be constructed for indexOf and
lastIndexOf, and all of the algorithms in the
Collections class can be applied to a subList.The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)
subList in interface List<E>fromIndex - low endpoint (inclusive) of the subList.toIndex - high endpoint (exclusive) of the subList.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||