org.apache.http.message
Class AbstractHttpMessage

java.lang.Object
  extended by org.apache.http.message.AbstractHttpMessage
All Implemented Interfaces:
HttpMessage
Direct Known Subclasses:
BasicHttpRequest, BasicHttpResponse

public abstract class AbstractHttpMessage
extends java.lang.Object
implements HttpMessage

Basic implementation of an HTTP message that can be modified.

Since:
4.0
Version:
$Revision: 505893 $
Author:
Oleg Kalnichevski

Constructor Summary
protected AbstractHttpMessage()
           
 
Method Summary
 void addHeader(Header header)
          Adds a header to this message.
 void addHeader(java.lang.String name, java.lang.String value)
          Adds a header to this message.
 boolean containsHeader(java.lang.String name)
          Checks if a certain header is present in this message.
 Header[] getAllHeaders()
          Returns all the headers of this message.
 Header getFirstHeader(java.lang.String name)
          Returns the first header with a specified name of this message.
 Header[] getHeaders(java.lang.String name)
          Returns all the headers with a specified name of this message.
 Header getLastHeader(java.lang.String name)
          Returns the last header with a specified name of this message.
 HttpParams getParams()
          Returns the parameters effective for this message as set by
 java.util.Iterator headerIterator()
          Returns an iterator of all the headers.
 void removeHeader(Header header)
          Removes a header from this message.
 void removeHeaders(java.lang.String name)
          Removes all headers with a certain name from this message.
 void setHeader(Header header)
          Overwrites the first header with the same name.
 void setHeader(java.lang.String name, java.lang.String value)
          Overwrites the first header with the same name.
 void setHeaders(Header[] headers)
          Overwrites all the headers in the message.
 void setParams(HttpParams params)
          Provides parameters to be used for the processing of this message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.http.HttpMessage
getHttpVersion
 

Constructor Detail

AbstractHttpMessage

protected AbstractHttpMessage()
Method Detail

containsHeader

public boolean containsHeader(java.lang.String name)
Description copied from interface: HttpMessage
Checks if a certain header is present in this message. Header values are ignored.

Specified by:
containsHeader in interface HttpMessage
Parameters:
name - the header name to check for.
Returns:
true if at least one header with this name is present.

getHeaders

public Header[] getHeaders(java.lang.String name)
Description copied from interface: HttpMessage
Returns all the headers with a specified name of this message. Header values are ignored. Headers are orderd in the sequence they will be sent over a connection.

Specified by:
getHeaders in interface HttpMessage
Parameters:
name - the name of the headers to return.
Returns:
the headers whose name property equals name.

getFirstHeader

public Header getFirstHeader(java.lang.String name)
Description copied from interface: HttpMessage
Returns the first header with a specified name of this message. Header values are ignored. If there is more than one matching header in the message the first element of

Specified by:
getFirstHeader in interface HttpMessage
Parameters:
name - the name of the header to return.
Returns:
the first header whose name property equals name.

getLastHeader

public Header getLastHeader(java.lang.String name)
Description copied from interface: HttpMessage
Returns the last header with a specified name of this message. Header values are ignored. If there is more than one matching header in the message the last element of

Specified by:
getLastHeader in interface HttpMessage
Parameters:
name - the name of the header to return.
Returns:
the last header whose name property equals name.

getAllHeaders

public Header[] getAllHeaders()
Description copied from interface: HttpMessage
Returns all the headers of this message. Headers are orderd in the sequence they will be sent over a connection.

Specified by:
getAllHeaders in interface HttpMessage
Returns:
all the headers of this message

addHeader

public void addHeader(Header header)
Description copied from interface: HttpMessage
Adds a header to this message. The header will be appended to the end of the list.

Specified by:
addHeader in interface HttpMessage
Parameters:
header - the header to append.

addHeader

public void addHeader(java.lang.String name,
                      java.lang.String value)
Description copied from interface: HttpMessage
Adds a header to this message. The header will be appended to the end of the list.

Specified by:
addHeader in interface HttpMessage
Parameters:
name - the name of the header.
value - the value of the header.

setHeader

public void setHeader(Header header)
Description copied from interface: HttpMessage
Overwrites the first header with the same name. The new header will be appended to the end of the list, if no header with the given name can be found.

Specified by:
setHeader in interface HttpMessage
Parameters:
header - the header to set.

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
Description copied from interface: HttpMessage
Overwrites the first header with the same name. The new header will be appended to the end of the list, if no header with the given name can be found.

Specified by:
setHeader in interface HttpMessage
Parameters:
name - the name of the header.
value - the value of the header.

setHeaders

public void setHeaders(Header[] headers)
Description copied from interface: HttpMessage
Overwrites all the headers in the message.

Specified by:
setHeaders in interface HttpMessage
Parameters:
headers - the array of headers to set.

removeHeader

public void removeHeader(Header header)
Description copied from interface: HttpMessage
Removes a header from this message.

Specified by:
removeHeader in interface HttpMessage
Parameters:
header - the header to remove.

removeHeaders

public void removeHeaders(java.lang.String name)
Description copied from interface: HttpMessage
Removes all headers with a certain name from this message.

Specified by:
removeHeaders in interface HttpMessage
Parameters:
name - The name of the headers to remove.

headerIterator

public java.util.Iterator headerIterator()
Description copied from interface: HttpMessage
Returns an iterator of all the headers.

Specified by:
headerIterator in interface HttpMessage
Returns:
Iterator that returns Header objects in the sequence they are sent over a connection.

getParams

public HttpParams getParams()
Description copied from interface: HttpMessage
Returns the parameters effective for this message as set by

Specified by:
getParams in interface HttpMessage

setParams

public void setParams(HttpParams params)
Description copied from interface: HttpMessage
Provides parameters to be used for the processing of this message.

Specified by:
setParams in interface HttpMessage
Parameters:
params - the parameters


Copyright © 2005-2009 Apache Software Foundation. All Rights Reserved.