rabbit.http
Class GeneralHeader

java.lang.Object
  extended by rabbit.http.GeneralHeader
All Implemented Interfaces:
Externalizable, Serializable
Direct Known Subclasses:
HttpHeader, MultipartHeader

public class GeneralHeader
extends Object
implements Externalizable

A class to handle general headers.

Author:
Robert Olofsson
See Also:
Serialized Form

Field Summary
protected  List<Header> headers
          The headers of this Header in order.
 
Constructor Summary
GeneralHeader()
          Create a new HTTPHeader from scratch
 
Method Summary
 void addHeader(Header h)
          Add a new header.
 void addHeader(String type, String value)
          Add a new header.
 void copyHeader(GeneralHeader to)
          Copy all headers in this header to the given header.
 String getHeader(String type)
          get the value of header type
 List<String> getHeaders(String type)
          Get all headers of a specified type...
 void readExternal(ObjectInput in)
           
 void removeHeader(String type)
          removes a headerline from this header
 void removeValue(String value)
          removes a header with the specified value
 void setExistingValue(String current, String newValue)
          Set a specified header
 void setHeader(String type, String value)
          Set or replaces a value for given type.
 int size()
           
 String toString()
          Get the text value of this header
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

headers

protected List<Header> headers
The headers of this Header in order.

Constructor Detail

GeneralHeader

public GeneralHeader()
Create a new HTTPHeader from scratch

Method Detail

size

public int size()

toString

public String toString()
Get the text value of this header

Overrides:
toString in class Object
Returns:
a String describing this GeneralHeader.

getHeader

public String getHeader(String type)
get the value of header type

Parameters:
type - the Header were intrested in.
Returns:
the value of type or null if no value is set.

setHeader

public void setHeader(String type,
                      String value)
Set or replaces a value for given type.

Parameters:
type - the type or category that we want to set.
value - the value we want to set

setExistingValue

public void setExistingValue(String current,
                             String newValue)
Set a specified header

Parameters:
current - the type or category that we want to set.
newValue - the value we want to set

addHeader

public void addHeader(String type,
                      String value)
Add a new header. Old headers of the same type remain. The new header is placed last.

Parameters:
type - the type or category that we want to set.
value - the value we want to set

addHeader

public void addHeader(Header h)
Add a new header. Old headers of the same type remain. The new header is placed last.

Parameters:
h - the Header to add

removeHeader

public void removeHeader(String type)
removes a headerline from this header

Parameters:
type - the type we want to remove

removeValue

public void removeValue(String value)
removes a header with the specified value

Parameters:
value - the value of the header we want to remove

getHeaders

public List<String> getHeaders(String type)
Get all headers of a specified type...

Parameters:
type - the type of the headers to get, eg. "Cache-Control".

copyHeader

public void copyHeader(GeneralHeader to)
Copy all headers in this header to the given header.

Parameters:
to - the GeneralHeader to add headers to.

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException