org.greenstone.gs3client.data
Class ResponseData

java.lang.Object
  extended by org.greenstone.gs3client.data.ResponseData
Direct Known Subclasses:
BrowseResponseData, QueryResponseData

public abstract class ResponseData
extends java.lang.Object

Represents the data in a response XML message that is returned as either a Browse or Query (Search) request. Subclasses therefore are BrowseResponseData and QueryResponseData. This class maintains a Map of (nodeID, NodeData ref) pairs representing the resulting <classifierNode>s and <documentNode>s that can be returned when executing a SINGLE browse or query request.

Author:
ak19

Field Summary
protected  java.util.Map nodeIDsToNodes
          map of (nodeIDs, references to associated NodeData) pairs, stored in the order they are contained in the response XML messages (the order in which data objects are parsed and created for them)
 
Constructor Summary
ResponseData()
          Default constructor, creates the nodeIDsToNodes map
 
Method Summary
 void clear()
          Clears/resets this ResponseData object of all data, so that it can be reused to process future Browse and Query requests.
 java.util.Map getIDToNodeMapping()
           
 NodeData getNodeForID(java.lang.String ID)
          Given an nodeID, returns the NodeData object with that nodeID, if any.
 void setContentForDocs(org.w3c.dom.Element messageTag)
          After a DocumentContentRetrieve request for one or more documents has returned a response, this method - when given the response XML - will set the nodeContents of each document in the response (as long as those documents already have an associated DocumentNodeData object instantiated, which should/would always be the case).
 boolean setMetadataForDocuments(org.w3c.dom.Element messageTag)
          This method sets the metadata for one or even all <documentNode> data objects contained in the Map nodeIDsToNodes, using the <message> element parameter (which is returned upon a documentMetadataRetrieve request.
protected  boolean setMetadataForNodes(org.w3c.dom.Element messageTag, java.lang.String NODE_ELEM)
          This method can be called after a DocumentMetadataRetrieve request has returned a response.
abstract  void setResponseData(org.w3c.dom.Element responseMsgTag)
          Subclasses must implement this method to parse the <message><response></response></message> that is returned upon executing a browse or query request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nodeIDsToNodes

protected java.util.Map nodeIDsToNodes
map of (nodeIDs, references to associated NodeData) pairs, stored in the order they are contained in the response XML messages (the order in which data objects are parsed and created for them)

Constructor Detail

ResponseData

public ResponseData()
Default constructor, creates the nodeIDsToNodes map

Method Detail

setResponseData

public abstract void setResponseData(org.w3c.dom.Element responseMsgTag)
Subclasses must implement this method to parse the <message><response></response></message> that is returned upon executing a browse or query request. At the end of this method, the Map nodeIDsToNodes will contain any DocumentNodeData or ClassifierNodeData objects described in the responseMsgTag.

Parameters:
responseMsgTag - the XMl response message Element whose data will be parsed and stored in the ResponseData subclass

clear

public void clear()
Clears/resets this ResponseData object of all data, so that it can be reused to process future Browse and Query requests. In this case, it merely clears the internal Map nodeIDsToNodes. Subclasses may need to clear other variables.


getIDToNodeMapping

public java.util.Map getIDToNodeMapping()
Returns:
the Map of mappings from nodeIDs to NodeData object references

getNodeForID

public NodeData getNodeForID(java.lang.String ID)
Given an nodeID, returns the NodeData object with that nodeID, if any. Otherwise, null is returned. Subclass might want to add a different method that converts this to DocumentNodeData type.

Parameters:
ID - is the nodeID whose NodeData object is requested

setContentForDocs

public void setContentForDocs(org.w3c.dom.Element messageTag)
After a DocumentContentRetrieve request for one or more documents has returned a response, this method - when given the response XML - will set the nodeContents of each document in the response (as long as those documents already have an associated DocumentNodeData object instantiated, which should/would always be the case).

Parameters:
messageTag - is the DocumentContentRetrieve XML response message containing the document contents for one or more documentNodes

setMetadataForNodes

protected boolean setMetadataForNodes(org.w3c.dom.Element messageTag,
                                      java.lang.String NODE_ELEM)
This method can be called after a DocumentMetadataRetrieve request has returned a response. Given the response message (XML) element, this method attempts to set the metadata for all the documentNodeData objects it has, using the metadata tags in the response-message-XML. This method returns false if the responseMessage XMl does not contain any <documentNodeList> elements.

Parameters:
NODE_ELEM - can be either GSXML defined constant for <ClassifierNode> or <DocumentNode>
messageTag - is the DocumentMetadataRetrieve XML response message containing the metadata for one or more documentNodes/classifierNodes as specified by NODE_ELEM

setMetadataForDocuments

public boolean setMetadataForDocuments(org.w3c.dom.Element messageTag)
This method sets the metadata for one or even all <documentNode> data objects contained in the Map nodeIDsToNodes, using the <message> element parameter (which is returned upon a documentMetadataRetrieve request. Metadata for <classifierNodes> are not set with this method. It merely calls the setMetadataForDocuments(messageTag, tagName) method to parse out data for the tagName=<documentNode>.

Parameters:
messageTag - is the DocumentMetadataRetrieve XML response message containing the metadata for one or more documentNodes