org.sakaiproject.tool.search
Class QueryBase

java.lang.Object
  extended byorg.sakaiproject.tool.search.QueryBase
All Implemented Interfaces:
QueryInterface
Direct Known Subclasses:
HttpTransactionQueryBase

public abstract class QueryBase
extends Object
implements QueryInterface

This module provides a single, core implementation of SearchQueryInterface. It's referenced in the search servlet, Search.java, to obtain "lowest common denominator" functionality. In reality, each search application should extend QueryBase and implement appropriate methods. See HttpTransactionQueryBase.java for an example.


Field Summary
 
Fields inherited from interface org.sakaiproject.tool.search.QueryInterface
CS_DEFAULT, CS_ISO, CS_UTF8
 
Constructor Summary
QueryBase()
           
 
Method Summary
abstract  void doQuery(String baseURL)
          Do a query - there is no base implementation.
 String getImageCount()
          Fetch the desired image count
 String getParameter(String name, String value)
           
 String getRequestParameter(String name)
          Fetch a request parameter by name
 Map getRequestParameterMap()
          Fetch the entire request parameter Map
 String getResponseString()
          Get query results
 String getSearchString()
          Fetch the requested search text
 String getUrl()
          Get the URL for this query
 void parseRequest(Map parameterMap)
          Parse and save user request parameters.
protected  void populateRequestParameters(Map parameterMap)
          Populate user request parameters
 void setImageCount(String count)
          Specify desired number of images
 void setParameter(String name, String value)
          Set a named parameter related to this search.
 void setSearchString(String searchString)
          Specify search text
 void setUrl(String url)
          Set the URL for this query
 int submit()
          Submit a search request to the server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.sakaiproject.tool.search.QueryInterface
getParameter, initialize, setDefaultCharacterSet
 

Constructor Detail

QueryBase

public QueryBase()
Method Detail

doQuery

public abstract void doQuery(String baseURL)
Do a query - there is no base implementation.


populateRequestParameters

protected void populateRequestParameters(Map parameterMap)
Populate user request parameters

Parameters:
parameterMap - Request details as a map (name=value pairs)

parseRequest

public void parseRequest(Map parameterMap)
Parse and save user request parameters. This base method supports only the standard, simple query format. Override if necessary.

Specified by:
parseRequest in interface QueryInterface
Parameters:
parameterMap - Request details (name=value pairs)

getRequestParameter

public String getRequestParameter(String name)
Fetch a request parameter by name

Specified by:
getRequestParameter in interface QueryInterface
Parameters:
name - Parameter name
Returns:
Parameter value

getRequestParameterMap

public Map getRequestParameterMap()
Fetch the entire request parameter Map

Specified by:
getRequestParameterMap in interface QueryInterface
Returns:
Parameter Map

getImageCount

public String getImageCount()
Fetch the desired image count

Specified by:
getImageCount in interface QueryInterface
Returns:
The desired number of images

setImageCount

public void setImageCount(String count)
Description copied from interface: QueryInterface
Specify desired number of images

Specified by:
setImageCount in interface QueryInterface
Parameters:
count - Count of images requested from the search engine

setUrl

public void setUrl(String url)
Description copied from interface: QueryInterface
Set the URL for this query

Specified by:
setUrl in interface QueryInterface
Parameters:
url - The requested URL

getUrl

public String getUrl()
Description copied from interface: QueryInterface
Get the URL for this query

Specified by:
getUrl in interface QueryInterface
Returns:
The requested URL

setSearchString

public void setSearchString(String searchString)
Description copied from interface: QueryInterface
Specify search text

Specified by:
setSearchString in interface QueryInterface
Parameters:
searchString - Text to search for

getSearchString

public String getSearchString()
Description copied from interface: QueryInterface
Fetch the requested search text

Specified by:
getSearchString in interface QueryInterface
Returns:
The search text

setParameter

public void setParameter(String name,
                         String value)
Description copied from interface: QueryInterface
Set a named parameter related to this search. Sent to the search server, this is usually a modifier for the search (return ## matches, etc)

Specified by:
setParameter in interface QueryInterface
Parameters:
name - Parameter name
value - Parameter value

getParameter

public String getParameter(String name,
                           String value)

submit

public int submit()
Description copied from interface: QueryInterface
Submit a search request to the server

Specified by:
submit in interface QueryInterface
Returns:
Server status (ala HTTP, 200 is success)

getResponseString

public String getResponseString()
Description copied from interface: QueryInterface
Get query results

Specified by:
getResponseString in interface QueryInterface
Returns:
The results page (as a String)