net.groboclown.util.http.v1
Class HttpResponseMessageImpl

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

public class HttpResponseMessageImpl
extends Object
implements IHttpResponseMessage

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

Field Summary
private  Vector m_headerNames
           
private  Hashtable m_headers
           
private  String m_httpVersion
           
private  byte[] m_message
           
private  int m_statusCode
           
private  String m_statusMessage
           
private  URL m_url
           
 
Constructor Summary
protected HttpResponseMessageImpl(String uri)
          Default constructor - protected protection
protected HttpResponseMessageImpl(URL url)
           
 
Method Summary
protected  void addHeader(String name, String value)
           
 String getHeader(String name)
          Returns the first value encountered of the header with the given name.
 Enumeration getHeaderNames()
          Returns an enumeration of all the names of the headers received in the message.
 String[] getHeaders(String name)
          Returns all the values encountered of the header with the given name, or null if there were none.
 String getHTTPVersion()
          Returns the server's HTTP version, of the form:
 int getIntHeader(String name)
          Returns the first value encountered of the header with the given name as an integer.
 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.
protected  void setHTTPVersion(String version)
           
protected  void setMessage(byte[] message)
           
protected  void setStatus(int code, String message)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

m_httpVersion

private String m_httpVersion

m_headers

private Hashtable m_headers

m_headerNames

private Vector m_headerNames

m_message

private byte[] m_message

m_statusCode

private int m_statusCode

m_statusMessage

private String m_statusMessage

m_url

private URL m_url
Constructor Detail

HttpResponseMessageImpl

protected HttpResponseMessageImpl(String uri)
Default constructor - protected protection

HttpResponseMessageImpl

protected HttpResponseMessageImpl(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()

getHeaderNames

public Enumeration getHeaderNames()
Description copied from interface: IHttpResponseMessage
Returns an enumeration of all the names of the headers received in the message.

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)
Description copied from interface: IHttpResponseMessage
Returns the first value encountered of the header with the given name. If there are multiple values associated with the header, only the first one is returned.

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)
Description copied from interface: IHttpResponseMessage
Returns all the values encountered of the header with the given name, or null if there were none.

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)
Description copied from interface: IHttpResponseMessage
Returns the first value encountered of the header with the given name as an integer. If there are multiple values associated with the header, only the first one is returned. If the name was not present, or the value was not a valid integer, then -1 is returned.

Note that header names are case-insensitive.

Specified by:
getIntHeader in interface IHttpResponseMessage
Returns:
-1 if there was an error parsing the number.

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()

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()

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

addHeader

protected void addHeader(String name,
                         String value)

setMessage

protected void setMessage(byte[] message)

setStatus

protected void setStatus(int code,
                         String message)

setHTTPVersion

protected void setHTTPVersion(String version)


Written under the LGPL