net.groboclown.util.http.v1.tests
Class SimpleHttpResponseMessage

java.lang.Object
  |
  +--net.groboclown.util.http.v1.tests.SimpleHttpResponseMessage
All Implemented Interfaces:
IHttpResponseMessage

public class SimpleHttpResponseMessage
extends Object
implements IHttpResponseMessage

Since:
Alpha 0.9.0
Version:
Alpha 0.9.1
Author:
Matt Albrecht

Field Summary
private  Hashtable headers
           
private  String httpVersion
           
private  byte[] message
           
private  int statusCode
           
private  String statusString
           
private  URL url
           
 
Constructor Summary
SimpleHttpResponseMessage(URL url)
           
 
Method Summary
 void addHeader(String name, String value)
           
 void addHeaders(String name, String[] values)
           
 void addIntHeaders(String name, int value)
           
 String getHeader(String name)
          Note that header names are case-insensitive.
 Enumeration getHeaderNames()
          Note that header names are case-insensitive.
 String[] getHeaders(String name)
          Note that header names are case-insensitive.
 String getHTTPVersion()
          Returns the server's HTTP version, of the form:
 int getIntHeader(String name)
          Note that header names are case-insensitive.
 byte[] getMessage()
          Retrieves the message body in bytes.
 int getMessageSize()
          Retrieves the actual size of the returned message body.
 int getStatusCode()
          Returns the status number associated with the message.
 String getStatusMessage()
          Returns the status message associated with the message's status code.
 String getURI()
          Retrieve the URI which returned this message.
 URL getURL()
          Retrieve the URL which returned this message.
 void removeHeaders(String name)
           
 void setHTTPVersion(String v)
           
 void setStatusCode(int code)
           
 void setStatusMessage(String m)
           
 void setURL(URL url)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

headers

private Hashtable headers

url

private URL url

httpVersion

private String httpVersion

message

private byte[] message

statusCode

private int statusCode

statusString

private String statusString
Constructor Detail

SimpleHttpResponseMessage

public SimpleHttpResponseMessage(URL url)
Method Detail

getURI

public String getURI()
Description copied from interface: IHttpResponseMessage
Retrieve the URI which returned this message.
Specified by:
getURI in interface IHttpResponseMessage
Following copied from interface: net.groboclown.util.http.v1.IHttpResponseMessage
Returns:
the URI of the request message that generated this response.
See Also:
IHttpResponseMessage.getURL()

getURL

public URL getURL()
Description copied from interface: IHttpResponseMessage
Retrieve the URL which returned this message.
Specified by:
getURL in interface IHttpResponseMessage
Following copied from interface: net.groboclown.util.http.v1.IHttpResponseMessage
Returns:
the URL of the request message that generated this response.
See Also:
IHttpResponseMessage.getURI()

setURL

public void setURL(URL url)

getHeaderNames

public Enumeration getHeaderNames()
Note that header names are case-insensitive.
Specified by:
getHeaderNames in interface IHttpResponseMessage
Following copied from interface: net.groboclown.util.http.v1.IHttpResponseMessage
Returns:
the collection of header names that were in the message.

getHeader

public String getHeader(String name)
Note that header names are case-insensitive.
Specified by:
getHeader in interface IHttpResponseMessage
Following copied from interface: net.groboclown.util.http.v1.IHttpResponseMessage
Returns:
the value of header name that was in the message. If there was no such header name, then null is returned. If there were multiple headers of that name, then only the first is returned.
See Also:
IHttpResponseMessage.getHeaders( String ), IHttpResponseMessage.getIntHeader( String )

getHeaders

public String[] getHeaders(String name)
Note that header names are case-insensitive.
Specified by:
getHeaders in interface IHttpResponseMessage
Following copied from interface: net.groboclown.util.http.v1.IHttpResponseMessage
Returns:
the value of header name that was in the message. If there was no such header name, then null is returned. If there were multiple headers of that name, then only the first is returned.
See Also:
IHttpResponseMessage.getHeader( String ), IHttpResponseMessage.getIntHeader( String )

getIntHeader

public int getIntHeader(String name)
Note that header names are case-insensitive.
Specified by:
getIntHeader in interface IHttpResponseMessage
Returns:
-1 if there was an error parsing the number.

addHeader

public void addHeader(String name,
                      String value)

addHeaders

public void addHeaders(String name,
                       String[] values)

addIntHeaders

public void addIntHeaders(String name,
                          int value)

removeHeaders

public void removeHeaders(String name)

getMessageSize

public int getMessageSize()
Description copied from interface: IHttpResponseMessage
Retrieves the actual size of the returned message body.
Specified by:
getMessageSize in interface IHttpResponseMessage

getStatusCode

public int getStatusCode()
Description copied from interface: IHttpResponseMessage
Returns the status number associated with the message.
Specified by:
getStatusCode in interface IHttpResponseMessage
Following copied from interface: net.groboclown.util.http.v1.IHttpResponseMessage
See Also:
IHttpResponseMessage.getStatusMessage()

setStatusCode

public void setStatusCode(int code)

getStatusMessage

public String getStatusMessage()
Description copied from interface: IHttpResponseMessage
Returns the status message associated with the message's status code.
Specified by:
getStatusMessage in interface IHttpResponseMessage
Following copied from interface: net.groboclown.util.http.v1.IHttpResponseMessage
See Also:
IHttpResponseMessage.getStatusCode()

setStatusMessage

public void setStatusMessage(String m)

getMessage

public byte[] getMessage()
Description copied from interface: IHttpResponseMessage
Retrieves the message body in bytes. Even though the messages usually consist of characters, it can return an octet-stream of binary data.
Specified by:
getMessage in interface IHttpResponseMessage

getHTTPVersion

public String getHTTPVersion()
Description copied from interface: IHttpResponseMessage
Returns the server's HTTP version, of the form:
      HTTP/a.i
 
where a is the major version, and i is the minor version. Currently, the only valid values are HTTP/1.0 and HTTP/1.1.
Specified by:
getHTTPVersion in interface IHttpResponseMessage

setHTTPVersion

public void setHTTPVersion(String v)


Written under the LGPL