googlesearch
Class ResultPageStore

java.lang.Object
  extended by googlesearch.ResultPageStore

public class ResultPageStore
extends java.lang.Object

A storage mechanism for the result pages returned by queries. Allows you to save some of the results for later without running the search again. This is a multi-map. For one key (a Query) you can save several results.

Author:
jbergin

Constructor Summary
ResultPageStore()
           
 
Method Summary
 void clear()
           
 java.util.List<SearchResultPage> get(Query key)
          Retrieve a List of the pages stored associated with this Query
 java.util.Iterator<Query> keys()
          Obtain an iterator over the keys used in the storage
 void put(Query key, java.util.Collection pages)
          Put all of the pages into the storage with the given key
 void put(Query key, SearchResultPage page)
          Insert a page into storage with a query as key.
 void remove(Query key)
          Remove all the pages with a given key
 void remove(Query key, SearchResultPage page)
          Remove a single page from the storage by key.
 java.util.Iterator<java.util.List<SearchResultPage>> values()
          Obtain an iterator over the values stored.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResultPageStore

public ResultPageStore()
Method Detail

put

public void put(Query key,
                SearchResultPage page)
Insert a page into storage with a query as key. Several pages may be stored with the same query. They are maintained in a list in the order inserted.

Parameters:
key - a query used to tag the saved page
page - a page to save

put

public void put(Query key,
                java.util.Collection pages)
Put all of the pages into the storage with the given key

Parameters:
key - the retrieval key used to get the pages back
pages - the pages to store with this key

remove

public void remove(Query key,
                   SearchResultPage page)
Remove a single page from the storage by key. Does nothing if the page isn't in the storage with this key.

Parameters:
key - the key used to store the page
page - the page to be removed.

remove

public void remove(Query key)
Remove all the pages with a given key

Parameters:
key - the key whose pages should be removed.

clear

public void clear()

get

public java.util.List<SearchResultPage> get(Query key)
Retrieve a List of the pages stored associated with this Query

Parameters:
key - the Query whose pages were previously stored
Returns:
a List (possibly empty) of pages store with the key

keys

public java.util.Iterator<Query> keys()
Obtain an iterator over the keys used in the storage

Returns:
an iterator over the keys

values

public java.util.Iterator<java.util.List<SearchResultPage>> values()
Obtain an iterator over the values stored. The iterator will return List objects

Returns:
an iterator over the lists of values.