rabbit.http
Class GeneralHeader

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

public class GeneralHeader
extends Object
implements Storable

A class to handle general headers.

Author:
Robert Olofsson

Field Summary
protected  ArrayList<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.
protected  void fillBuffer(StringBuilder sb)
          Fill the given StringBuilder with text from this header.
 String getHeader(String type)
          get the value of header type
 List<String> getHeaders(String type)
          Get all headers of a specified type...
 void read(DataInput in)
          Fill in this object with data from the given input.
 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()
          Get the number of headers set in this header.
 String toString()
          Get the text value of this header
 void write(DataOutput out)
          Write this object to the given output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

headers

protected ArrayList<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()
Get the number of headers set in this header.


toString

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

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

fillBuffer

protected void fillBuffer(StringBuilder sb)
Fill the given StringBuilder with text from this header.


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.

read

public void read(DataInput in)
          throws IOException
Description copied from interface: Storable
Fill in this object with data from the given input.

Specified by:
read in interface Storable
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Description copied from interface: Storable
Write this object to the given output.

Specified by:
write in interface Storable
Throws:
IOException