org.cdlib.xtf.crossQuery
Class CrossQuery

Object
  extended by GenericServlet
      extended by HttpServlet
          extended by TextServlet
              extended by CrossQuery
All Implemented Interfaces:
Serializable, Servlet, ServletConfig
Direct Known Subclasses:
RawQuery, SRU, TestableCrossQuery

public class CrossQuery
extends TextServlet

The crossQuery servlet coordinates the process of parsing a URL query, activating the textEngine to find all occurrences, and finally formatting the results.

See Also:
Serialized Form

Field Summary
protected  CrossQueryConfig config
          Holds global servlet configuration info
protected static DecimalFormat decimalFormat
          Used to format decimal numbers
protected  TimeProfilingListener profListener
          Used for stylesheet profiling, if enabled
 
Fields inherited from class TextServlet
stylesheetCache
 
Constructor Summary
CrossQuery()
           
 
Method Summary
protected  void apply(AttribList attribs, HttpServletRequest req, HttpServletResponse res)
          Creates the query request, processes it, and formats the results.
 void doGet(HttpServletRequest req, HttpServletResponse res)
          Handles the HTTP 'get' method.
protected  void formatHits(String mainTagName, HttpServletRequest req, HttpServletResponse res, AttribList attribs, QueryRequest queryRequest, QueryResult queryResult, long startTime)
          Formats a list of hits using the resultFormatter stylesheet.
 TextConfig getConfig()
          Retrieves the current configuration information (that was read in by readConfig()).
 String getConfigName()
          Called by the superclass to find out the name of our specific config file.
 String getServletInfo()
          Informational method required by Servlet interface.
protected  TextConfig readConfig(String configPath)
          Loads the specific configuration file for crossQuery.
protected  QueryRequest runQueryParser(HttpServletRequest req, HttpServletResponse res, QueryRoute route, AttribList attribs)
          Creates a query request using the queryParser stylesheet and the given attributes.
protected  QueryRoute runQueryRouter(HttpServletRequest req, HttpServletResponse res, AttribList attribs)
          Creates a query request using the queryParser stylesheet and the given attributes.
protected  boolean shuntQueryReq(HttpServletRequest req, HttpServletResponse res, Source queryReqDoc)
          Called right after the raw query request has been generated, but before it is parsed.
protected  String stepSetup(HttpServletRequest req, HttpServletResponse res)
          Checks if step mode is active and in the setup phase.
 
Methods inherited from class TextServlet
addParam, addToken, addTokens, buildParamBlock, calcMimeType, convertUTF8inURL, cqlTokenize, createFilteredReceiver, createQueryProcessor, decodeURL, defaultTokenize, destroy, doPost, genErrorPage, getCurRequest, getCurResponse, getCurServlet, getRealPath, getRequestURL, getRequestURL, getText, isEmpty, isSessionTrackingEnabled, makeAttribList, makeHtmlString, makeHtmlString, rawTokenize, readBranding, requireOrElse, restoreWildcards, saveWildcards, service, setErrorGenSheet, setupTrace, stuffAttribs, stuffAttribs, stuffSpecialAttribs
 
Methods inherited from class HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service
 
Methods inherited from class GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, init, log, log
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

config

protected CrossQueryConfig config
Holds global servlet configuration info


decimalFormat

protected static DecimalFormat decimalFormat
Used to format decimal numbers


profListener

protected TimeProfilingListener profListener
Used for stylesheet profiling, if enabled

Constructor Detail

CrossQuery

public CrossQuery()
Method Detail

getConfigName

public String getConfigName()
Called by the superclass to find out the name of our specific config file.

Specified by:
getConfigName in class TextServlet

readConfig

protected TextConfig readConfig(String configPath)
Loads the specific configuration file for crossQuery.

Specified by:
readConfig in class TextServlet
Parameters:
configPath - Path to the configuration file
Returns:
Parsed config information

getConfig

public TextConfig getConfig()
Retrieves the current configuration information (that was read in by readConfig()).

Specified by:
getConfig in class TextServlet

doGet

public void doGet(HttpServletRequest req,
                  HttpServletResponse res)
           throws IOException
Handles the HTTP 'get' method. Initializes the servlet if nececssary, then parses the HTTP request and processes it appropriately.

Specified by:
doGet in class TextServlet
Parameters:
req - The HTTP request (in)
res - The HTTP response (out)
Throws:
IOException - If unable to read an index or data file, or if unable to write the output stream.

getServletInfo

public String getServletInfo()
Informational method required by Servlet interface. Doesn't seem to matter what it says.

Specified by:
getServletInfo in interface Servlet
Overrides:
getServletInfo in class GenericServlet
Returns:
A string describing this servlet.

apply

protected void apply(AttribList attribs,
                     HttpServletRequest req,
                     HttpServletResponse res)
              throws Exception
Creates the query request, processes it, and formats the results.

Parameters:
attribs - Attributes to pass to the stylesheets.
req - The original HTTP request
res - Where to send the response
Throws:
Exception - Passes on various errors that might occur.

runQueryRouter

protected QueryRoute runQueryRouter(HttpServletRequest req,
                                    HttpServletResponse res,
                                    AttribList attribs)
                             throws Exception
Creates a query request using the queryParser stylesheet and the given attributes.

Parameters:
req - The original HTTP request
res - The HTTP response (used for step mode only)
attribs - Attributes to pass to the stylesheet.
Returns:
A route to the parser, or null if before that step
Throws:
Exception

runQueryParser

protected QueryRequest runQueryParser(HttpServletRequest req,
                                      HttpServletResponse res,
                                      QueryRoute route,
                                      AttribList attribs)
                               throws Exception
Creates a query request using the queryParser stylesheet and the given attributes.

Parameters:
req - The original HTTP request
res - The HTTP response (used for step mode only)
route - Route to the query parser
attribs - Attributes to pass to the stylesheet.
Returns:
A parsed query request, or null if before that step
Throws:
Exception

shuntQueryReq

protected boolean shuntQueryReq(HttpServletRequest req,
                                HttpServletResponse res,
                                Source queryReqDoc)
                         throws IOException
Called right after the raw query request has been generated, but before it is parsed. Gives us a chance to stop processing here in step mode.

Throws:
IOException

formatHits

protected void formatHits(String mainTagName,
                          HttpServletRequest req,
                          HttpServletResponse res,
                          AttribList attribs,
                          QueryRequest queryRequest,
                          QueryResult queryResult,
                          long startTime)
                   throws Exception
Formats a list of hits using the resultFormatter stylesheet.

Parameters:
mainTagName - Name of the top-level tag to generate (e.g. "crossQueryResult", etc.)
req - The original HTTP request
res - Where to send the HTML response
attribs - Parameters to pass to the stylesheet
queryRequest - Query request that produced the hits
queryResult - Hits resulting from the query request
startTime - Time (in milliseconds) request began
Throws:
Exception

stepSetup

protected String stepSetup(HttpServletRequest req,
                           HttpServletResponse res)
                    throws IOException
Checks if step mode is active and in the setup phase. If so, outputs the frameset and information frames.

Parameters:
req - The HTTP request (in)
res - The HTTP response (out)
Returns:
A string to output if in step setup phase, null to do normal processing
Throws:
IOException