googlesearch
Class QueryStore

java.lang.Object
  extended by googlesearch.QueryStore

public class QueryStore
extends java.lang.Object

A storage mechanism for queries. Queries are stored with a user-supplied name. The name can be later used to retrieve a query.

Author:
jbergin

Constructor Summary
QueryStore()
           
 
Method Summary
 void clear()
          Remove all the queries from the storage.
 Query get(java.lang.String key)
          Retrieve a query with a given "name" or the NULL_QUERY if no query with the name is stored
 java.util.Iterator<java.lang.String> keys()
          Obtain an iterator over the keys.
 void put(java.lang.String key, Query query)
          Insert a query into the storage tagged with a name of your choosing.
 void remove(java.lang.String key)
          Remove a given query from the storage
 java.util.Iterator<Query> values()
          Obtain an iterator over all the Queries in the storage
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryStore

public QueryStore()
Method Detail

put

public void put(java.lang.String key,
                Query query)
Insert a query into the storage tagged with a name of your choosing. You can retrieve the query later by using the same name. Single word names without punctuation are preferred as they are a bit safer in use.

Parameters:
key - a name of your choosing to use as the retrieval key
query - the query to be saved

get

public Query get(java.lang.String key)
Retrieve a query with a given "name" or the NULL_QUERY if no query with the name is stored

Parameters:
key - the "key" used when a query was stored
Returns:
the Query associated with this name or the NULL_QUERY if there is no such

remove

public void remove(java.lang.String key)
Remove a given query from the storage

Parameters:
key - the name of the query to be removed

clear

public void clear()
Remove all the queries from the storage. Empty the storage.


keys

public java.util.Iterator<java.lang.String> keys()
Obtain an iterator over the keys.

Returns:
an iterator that will return all the keys in the storage

values

public java.util.Iterator<Query> values()
Obtain an iterator over all the Queries in the storage

Returns:
an iterator that will return all the queries in the storage.