com.pushtotest.tool.response
Class ResponseWrapper

java.lang.Object
  extended by com.pushtotest.tool.response.ResponseWrapper
All Implemented Interfaces:
Response
Direct Known Subclasses:
FileResponse, HTTPResponse, MailResponse, SOAPResponse, XMLRPCResponse

public abstract class ResponseWrapper
extends java.lang.Object
implements Response

This is an abstract class that implements the Response interface that should make it easy to deal with some of the details of the Response by providing reasonable default implementations of each of the methods.


Field Summary
protected  java.lang.Object content
           
protected  long datatime
           
protected  java.util.Map parameters
           
protected  Protocol parent
           
protected  int responsecode
           
protected  java.lang.String responseMessage
           
protected  long setuptime
           
protected  long totaltime
           
 
Constructor Summary
ResponseWrapper()
           
 
Method Summary
 void appendParameter(java.lang.String name, java.lang.Object value)
          This method appends an Object to a parameter that is already stored or creates a new parameter if name is not used already.
 void appendParameters(java.lang.String name, java.util.List values)
          This method appends a List of Objects to a parameter that is already stored or creates a new parameter if name is not used already.
 java.lang.Object getContent()
          This method returns the entire contents that comprised the response that was sent back from the server.
 int getContentSize()
          Returns the size of the content.
 long getDataTime()
          Returns the time it took from recieving back the first byte of data until the last byte of data was recieved.
 java.util.Iterator getParameterKeys()
          Returns an Itterator of all of the parameters values so that they user can get the list and then get the values.
 java.lang.Object getParameterValue(java.lang.String name)
          Returns a single value that is associated with the name given.
 java.util.List getParameterValues(java.lang.String name)
          Returns the values associated with this parameter as a List.
 Protocol getParentProtocol()
          Returns the Protocol that was called that generated this Response object.
 int getResponseCode()
          Returns the response code value received from the host
 java.lang.String getResponseMessage()
          Returns the response code message.
 long getSetupTime()
          Returns the amount of time between when the connection is started and the first byte of data is recieved back from the server.
 long getTotalTime()
          Returns the total time it took to connect to the host, make the request and get all of the data back.
abstract  java.lang.String id()
          Gets the id of this response object.
 void setContent(java.lang.Object content)
          This method sets the entire contents that comprised the response that was sent back from the server.
 void setDataTime(long millis)
          Sets the time it took from recieving back the first byte of data until the last byte of data was recieved.
 void setParameter(java.lang.String name, java.lang.Object value)
          This method stores something in this response to be used later by a process.
 void setParameters(java.lang.String name, java.util.List values)
          Sets a List of parameters to be stored with the associated name.
 void setParentProtocol(Protocol parent)
          Sets the parent protocol of this Response object.
 void setResponseCode(int thecode)
          Sets the response code value, used internally
 void setResponseMessage(java.lang.String rmsg)
          Sets the response code message.
 void setSetupTime(long millis)
          Returns the amount of time between when the connection is started and the first byte of data is recieved back from the server.
 void setTotalTime(long millis)
          Sets the total time it took to connect to the host, make the request and get all of the data back.
 java.lang.String toString()
          Returns a string representation of all of the content that was returned from the server that made up this Response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parameters

protected java.util.Map parameters

parent

protected Protocol parent

content

protected java.lang.Object content

responsecode

protected int responsecode

responseMessage

protected java.lang.String responseMessage

totaltime

protected long totaltime

datatime

protected long datatime

setuptime

protected long setuptime
Constructor Detail

ResponseWrapper

public ResponseWrapper()
Method Detail

id

public abstract java.lang.String id()
Gets the id of this response object. This id should correspond to the id that is used by the Protocol object used to get this response type.

Specified by:
id in interface Response
Returns:
The name of the protocol that this response is from.

setResponseCode

public void setResponseCode(int thecode)
Sets the response code value, used internally

Specified by:
setResponseCode in interface Response
Parameters:
int - responsecode

getResponseCode

public int getResponseCode()
Returns the response code value received from the host

Specified by:
getResponseCode in interface Response
Returns:
String responsecode received

getResponseMessage

public java.lang.String getResponseMessage()
Returns the response code message. For example: HTTP/1.0 200 OK

Specified by:
getResponseMessage in interface Response

setResponseMessage

public void setResponseMessage(java.lang.String rmsg)
Sets the response code message. For example: HTTP/1.0 200 OK

Specified by:
setResponseMessage in interface Response

getParentProtocol

public Protocol getParentProtocol()
Returns the Protocol that was called that generated this Response object.

Specified by:
getParentProtocol in interface Response
Returns:
The Protocol that was used to get this Response.

setParentProtocol

public void setParentProtocol(Protocol parent)
                       throws UnsupportedTypeException
Sets the parent protocol of this Response object. This allows for 'bi-directionality'.

Specified by:
setParentProtocol in interface Response
Parameters:
parent - The Protocol that caused this Response to be returned.
Throws:
UnsupportedTypeException - If for some reason the Parent type and the the Response type are incompatible.

getContent

public java.lang.Object getContent()
This method returns the entire contents that comprised the response that was sent back from the server.

Specified by:
getContent in interface Response
Returns:
The content as a String.

setContent

public void setContent(java.lang.Object content)
This method sets the entire contents that comprised the response that was sent back from the server.

Specified by:
setContent in interface Response
Parameters:
The - content as a String.

toString

public java.lang.String toString()
Returns a string representation of all of the content that was returned from the server that made up this Response.

Specified by:
toString in interface Response
Overrides:
toString in class java.lang.Object
Returns:
The content that was returned from the server.

getContentSize

public int getContentSize()
Returns the size of the content.


setTotalTime

public void setTotalTime(long millis)
Sets the total time it took to connect to the host, make the request and get all of the data back.

Specified by:
setTotalTime in interface Response
Parameters:
millis - The time it took to do the whole connection.

getTotalTime

public long getTotalTime()
Returns the total time it took to connect to the host, make the request and get all of the data back.

Specified by:
getTotalTime in interface Response
Returns:
The total time it took to do the whole connection.

setDataTime

public void setDataTime(long millis)
Sets the time it took from recieving back the first byte of data until the last byte of data was recieved.

Specified by:
setDataTime in interface Response
Parameters:
millis - The time to get the data back from the host.

getDataTime

public long getDataTime()
Returns the time it took from recieving back the first byte of data until the last byte of data was recieved.

Specified by:
getDataTime in interface Response
Returns:
The time to get the data back from the host.

setSetupTime

public void setSetupTime(long millis)
Returns the amount of time between when the connection is started and the first byte of data is recieved back from the server.

Specified by:
setSetupTime in interface Response
Parameters:
millis - The amount of time it takes to connect and send the request.

getSetupTime

public long getSetupTime()
Returns the amount of time between when the connection is started and the first byte of data is recieved back from the server.

Specified by:
getSetupTime in interface Response
Returns:
The amount of time it takes to connect and send the request.

setParameter

public void setParameter(java.lang.String name,
                         java.lang.Object value)
This method stores something in this response to be used later by a process. This method replaces an Object that is stored with name if one already exists.

Specified by:
setParameter in interface Response
Parameters:
name - The name to store this as.
value - The object to associate with this name.

setParameters

public void setParameters(java.lang.String name,
                          java.util.List values)
Sets a List of parameters to be stored with the associated name. This is to handle 'multi-valued' parameters. Geoff 10/24/2001: Is storing generic objects ok? Will anyone know what to do with them later?

Specified by:
setParameters in interface Response
Parameters:
name - The name of the parameter.
values - The objects to associate with this param.

appendParameter

public void appendParameter(java.lang.String name,
                            java.lang.Object value)
This method appends an Object to a parameter that is already stored or creates a new parameter if name is not used already.

Specified by:
appendParameter in interface Response
Parameters:
name - The name of the parameter.
value - The object to associate with this param.

appendParameters

public void appendParameters(java.lang.String name,
                             java.util.List values)
This method appends a List of Objects to a parameter that is already stored or creates a new parameter if name is not used already.

Specified by:
appendParameters in interface Response
Parameters:
name - The name of the parameter.
values - The objects to associate with this param.

getParameterValue

public java.lang.Object getParameterValue(java.lang.String name)
Returns a single value that is associated with the name given. If the parameter is a multi-valued one, it will just return a value, with no guarantee as to which position it is in. If you know that it is a multi-valued, you should use the getParameterValues call instead.

Specified by:
getParameterValue in interface Response
Parameters:
name - The name of the parameter to get the value for.
See Also:
getParameterValues(java.lang.String)

getParameterKeys

public java.util.Iterator getParameterKeys()
Returns an Itterator of all of the parameters values so that they user can get the list and then get the values.

Specified by:
getParameterKeys in interface Response
Returns:
An Iterator to iterate over to get all of the values.

getParameterValues

public java.util.List getParameterValues(java.lang.String name)
Returns the values associated with this parameter as a List.

Specified by:
getParameterValues in interface Response
Parameters:
name - The name of the parameter to get the value for.