rabbit.http
Class GeneralHeader

java.lang.Object
  extended byrabbit.http.GeneralHeader
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
HTTPFooter, HTTPHeader

public class GeneralHeader
extends java.lang.Object
implements java.io.Serializable

A class to handle a general Header.

See Also:
Serialized Form

Field Summary
static java.lang.String CRLF
          The String consisting of \r and \n
 
Constructor Summary
GeneralHeader()
          Create a new HTTPHeader from scratch
GeneralHeader(java.io.DataInputStream in)
          Create a new HTTPHeader from scratch
 
Method Summary
 void addHeader(java.lang.String type, java.lang.String value)
          Add a new header.
 void copyHeader(GeneralHeader to)
          Copy all headers in this header to the given header.
 java.lang.String getHeader(java.lang.String type)
          get the value of header type
 java.util.Vector getHeaders(java.lang.String type)
          Get all headers of a specified type...
 void readHeader(java.io.DataInputStream in)
          Read in this header from the given Stream.
 void readHeader(java.io.DataInputStream in, java.lang.String firstline)
          Read in this header from the given Stream.
static java.lang.String readLine(java.io.DataInputStream in)
           
 void removeHeader(java.lang.String type)
          removes a headerline from this header
 void removeValue(java.lang.String value)
          removes a header with the specified value
 void setExistingValue(java.lang.String current, java.lang.String newValue)
          Set a specified header
 void setHeader(java.lang.String type, java.lang.String value)
          Set or replaces a value for given type.
 java.lang.String toString()
          Get the text value of this header
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CRLF

public static final java.lang.String CRLF
The String consisting of \r and \n

See Also:
Constant Field Values
Constructor Detail

GeneralHeader

public GeneralHeader()
Create a new HTTPHeader from scratch


GeneralHeader

public GeneralHeader(java.io.DataInputStream in)
              throws java.io.IOException
Create a new HTTPHeader from scratch

Method Detail

readHeader

public void readHeader(java.io.DataInputStream in)
                throws java.io.IOException
Read in this header from the given Stream. This actually merges the current header with the one beeing read.

Parameters:
in - the Stream to read the header from.
Throws:
java.io.IOException

readLine

public static java.lang.String readLine(java.io.DataInputStream in)
                                 throws java.io.IOException
Throws:
java.io.IOException

readHeader

public void readHeader(java.io.DataInputStream in,
                       java.lang.String firstline)
                throws java.io.IOException
Read in this header from the given Stream. This actually merges the current header with the one beeing read. This method is a convinience to have the abbility to read past the initial data before the header is read.

Parameters:
in - the Stream to read the header from.
firstline - the first line of this header.
Throws:
java.io.IOException

toString

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

Returns:
a String describing this GeneralHeader.

getHeader

public java.lang.String getHeader(java.lang.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(java.lang.String type,
                      java.lang.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(java.lang.String current,
                             java.lang.String newValue)
Set a specified header


addHeader

public void addHeader(java.lang.String type,
                      java.lang.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

removeHeader

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

Parameters:
type - the type we want to remove

removeValue

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

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

getHeaders

public java.util.Vector getHeaders(java.lang.String type)
Get all headers of a specified type...


copyHeader

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

Parameters:
to - the GeneralHeader to add headers to.