org.greenstone.gs3client.data
Class QueryResponseData

java.lang.Object
  extended by org.greenstone.gs3client.data.ResponseData
      extended by org.greenstone.gs3client.data.QueryResponseData

public class QueryResponseData
extends ResponseData

Represents the data fields that may be present in a response to a Query-process request. Specifically, this class keeps track of all the DocumentNodes returned in response to a query request. It inherits Map nodeIDsToNodes of (nodeID, NodeData ref) pairs which maintains the NodeData object refs in order of their insertion into the Map (LinkedHashMap). !!! QueryResponseData will only store DocumentNodeData object refs in the nodeIDsToNodes Map. An object of this class can be reused after instatiation by calling setResponseData() with a new query response XML message. This will first call clear() to clear/release its references to all the old data.

Author:
ak19

Nested Class Summary
static class QueryResponseData.TermData
          Static inner class Term represents a <term> XML element (these are nested in a <termList>) - see manual p.
 
Field Summary
protected  java.util.HashMap metadataList
          Metadata of the query's response - not a documentNode's metadata!
protected  java.lang.String numDocsMatched
           
protected  java.lang.String numDocsReturned
           
protected  java.lang.String queryField
           
protected  QueryResponseData.TermData[] termList
           
 
Fields inherited from class org.greenstone.gs3client.data.ResponseData
nodeIDsToNodes
 
Constructor Summary
QueryResponseData()
          Default constructor
 
Method Summary
 void clear()
          Resets the internal data members of this QueryResponseData object of their values so that this QueryResponseData can be reused for the next Query response message.
 DocumentNodeData getDocNodeForID(java.lang.String ID)
          Given an nodeID, returns the DocumentNodeData object with that nodeID if any.
 java.lang.String[] getDocumentNodeIDs()
           
 DocumentNodeData[] getDocumentNodeList()
           
 java.lang.String getMetaValueForName(java.lang.String name)
           
 java.lang.String getNumDocsMatched()
           
 java.lang.String getNumDocsReturned()
           
 java.lang.String getQueryField()
           
 QueryResponseData.TermData[] getTermList()
           
 void setResponseData(org.w3c.dom.Element responseMessageTag)
          Given the response to a query message (XML with root <message> or <response> tag), a QueryResponseData object is created to store all the document Identifiers and document data returned as well as information about the terms that were searched on.
 java.util.Vector setStructureForDocs(org.w3c.dom.Element messageTag)
          This method can be called after a DocumentStructureRetrieve request (for the entire structure of all/many of its documents) has returned a response.
 java.lang.String toString()
           
 
Methods inherited from class org.greenstone.gs3client.data.ResponseData
getIDToNodeMapping, getNodeForID, setContentForDocs, setMetadataForDocuments, setMetadataForNodes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

numDocsMatched

protected java.lang.String numDocsMatched

numDocsReturned

protected java.lang.String numDocsReturned

queryField

protected java.lang.String queryField

termList

protected QueryResponseData.TermData[] termList

metadataList

protected java.util.HashMap metadataList
Metadata of the query's response - not a documentNode's metadata!

Constructor Detail

QueryResponseData

public QueryResponseData()
Default constructor

Method Detail

clear

public void clear()
Resets the internal data members of this QueryResponseData object of their values so that this QueryResponseData can be reused for the next Query response message.

Overrides:
clear in class ResponseData

setResponseData

public void setResponseData(org.w3c.dom.Element responseMessageTag)
Given the response to a query message (XML with root <message> or <response> tag), a QueryResponseData object is created to store all the document Identifiers and document data returned as well as information about the terms that were searched on. Furthermore, metadata such as the number of Docs that matched and were returned (if any such are present in the response-message) are also stored. It first performs a clear to empty its data members and then fills them with the new Query response message's data.

Specified by:
setResponseData in class ResponseData
Parameters:
responseMessageTag - is the XML DOM Element representing a query response XML message.

getNumDocsMatched

public java.lang.String getNumDocsMatched()
Returns:
the number of matching documents for the query information

getNumDocsReturned

public java.lang.String getNumDocsReturned()
Returns:
the number of documents returned for the query information

getQueryField

public java.lang.String getQueryField()
Returns:
the query field information

getTermList

public QueryResponseData.TermData[] getTermList()
Returns:
the list of termData (search terms along with frequency information, etc.)

getDocNodeForID

public DocumentNodeData getDocNodeForID(java.lang.String ID)
Given an nodeID, returns the DocumentNodeData object with that nodeID if any. Otherwise, null is returned. Superclass has method getNodeForID that returns NodeData instead. This is just a convenience method.

Parameters:
ID - is the nodeID of the DocumentNodeData to be returned.
Returns:
the DocumentNodeData object for the given ID or null if not present.

getDocumentNodeList

public DocumentNodeData[] getDocumentNodeList()
Returns:
an array of the DocumentNodeData objects of the documents returned by the executed Query Response and stored in this QueryResponseData object. I.e. the documentNodes of the documents in the search results. In cases of an error (such as not being able to connect to a collection like Infomine) this method may return an empty array (length = 0) if docIDsToDocNodes is empty!

getDocumentNodeIDs

public java.lang.String[] getDocumentNodeIDs()
Returns:
an array of the IDs of the list of documentNodes maintained by this QueryResponseData object (the documentNodes of the documents' in the search results). In cases of an error (such as not being able to connect to collection such as Infomine) this method may return an empty array (length = 0) if docIDsToDocNodes is empty!

getMetaValueForName

public java.lang.String getMetaValueForName(java.lang.String name)
Returns:
metadata of the query's response. This includes values such as numDocsMatched, numDocsReturned, query. This does not return any document's metadata!

setStructureForDocs

public java.util.Vector setStructureForDocs(org.w3c.dom.Element messageTag)
This method can be called after a DocumentStructureRetrieve request (for the entire structure of all/many of its documents) has returned a response. Given the response message (XML) element, this method attempts to set the document structure for all the documentNodeData objects it has, using the nodeStructure tags in the response-message-XML. But only those documentNodeData whose nodeIDs are mentioned in the response-message-XML are actually set! This method returns a null vector if the responseMessage XMl does not contain any <documentNodeList> element with <documentNode>s each with <nodeStructure> children. Otherwise it returns a Vector of all the rootNodes of the list of docNodes that this QueryResponseData object maintains.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
some summary info on how the search went. This may include how many documents matched the query, and how many of them have been returned. With mult-term queries, the frequencies of each separate term is also returned for display.