net.rim.pushsdk.commons.http
Class HttpHeaderList

java.lang.Object
  extended by net.rim.pushsdk.commons.http.HttpHeaderList

public class HttpHeaderList
extends Object

Represents HTTP transport headers in the format of header name to header value pairs.

Author:
mdicesare

Field Summary
static String CONTENT_TRANSFER_ENCODING_HEADER
          The content transfer encoding HTTP header.
static String HEADER_KEY_VALUE_SEPARATOR
          The key-value separator for HTTP headers.
static String PUSH_MESSAGE_ID
          The push message id HTTP header (push id).
 
Constructor Summary
HttpHeaderList()
          Constructs an HTTP header list.
 
Method Summary
 void addHeader(String headerName, String headerValue)
          Adds a header value to an existing header in the list or creates the header and adds it to the list if it does not already exist.
 boolean containsHeader(String headerName)
          Whether or not the header list contains the given header name.
 String getHeader(String headerName)
          Gets the first header value for the given header name.
 Set<String> getHeaderNames()
          Gets the names of the headers in the header list.
 List<String> getHeaders(String headerName)
          Gets the list of values for the given header name.
 void setHeader(String headerName, String headerValue)
          Creates a header with the given header name and value and adds it to the list.
 int size()
          Gets the number of headers in the header list.
 String toString()
          Constructs a String with all attributes in name = value format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONTENT_TRANSFER_ENCODING_HEADER

public static final String CONTENT_TRANSFER_ENCODING_HEADER
The content transfer encoding HTTP header.

See Also:
Constant Field Values

HEADER_KEY_VALUE_SEPARATOR

public static final String HEADER_KEY_VALUE_SEPARATOR
The key-value separator for HTTP headers.

See Also:
Constant Field Values

PUSH_MESSAGE_ID

public static final String PUSH_MESSAGE_ID
The push message id HTTP header (push id).

See Also:
Constant Field Values
Constructor Detail

HttpHeaderList

public HttpHeaderList()
Constructs an HTTP header list.

Method Detail

size

public int size()
Gets the number of headers in the header list.

Returns:
the number of headers

getHeaderNames

public Set<String> getHeaderNames()
Gets the names of the headers in the header list.

Returns:
a set of header names

getHeader

public String getHeader(String headerName)
Gets the first header value for the given header name.

Parameters:
headerName - the header name
Returns:
the first header value; null if headerName is null

getHeaders

public List<String> getHeaders(String headerName)
Gets the list of values for the given header name.

Parameters:
headerName - the header name
Returns:
the list of header values; empty list if no headers; null if headerName is null

containsHeader

public boolean containsHeader(String headerName)
Whether or not the header list contains the given header name.

Parameters:
headerName - the header name
Returns:
true if the header could be found; false otherwise

addHeader

public void addHeader(String headerName,
                      String headerValue)
Adds a header value to an existing header in the list or creates the header and adds it to the list if it does not already exist.

Parameters:
headerName - the header name
headerValue - the header value

setHeader

public void setHeader(String headerName,
                      String headerValue)
Creates a header with the given header name and value and adds it to the list. If it already exists in the list, it will replace it.

Parameters:
headerName - the header name
headerValue - the header value

toString

public String toString()
Constructs a String with all attributes in name = value format.

Overrides:
toString in class Object
Returns:
a String representation of this object.


Copyright © 2011 Research In Motion. All Rights Reserved.