Class Header

java.lang.Object
  |
  +--Header
Direct Known Subclasses:
HTTPHeader

public class Header
extends java.lang.Object

A class to handle a general Header.


Inner Class Summary
protected  class Header.HeaderEntry
          This class holds a header entry, that has the folowing form "type: some text"
 
Field Summary
static java.lang.String CRLF
          The String consisting of \r and \n
static java.lang.String FIELD_SEPARATOR
          The Field separator
protected  java.util.Hashtable hHeaderEntries
          The hashtable of the headers. keys used are types, values are HeaderEntry Objects
 
Constructor Summary
Header()
          Create a new empty Header
Header(java.io.DataInputStream in)
          Create a new Header where entries are read from a given stream
 
Method Summary
 java.lang.String getHeaderEntryValue(java.lang.String type)
          get the value of header type
 void read(java.io.DataInputStream in)
          Read in this header from the given Stream.
 void read(java.io.DataInputStream in, java.lang.String firstline)
          Read in this header from the given Stream.
 void removeHeaderEntry(java.lang.String type)
          removes a headerline from this header
 void setHeaderEntry(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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

hHeaderEntries

protected java.util.Hashtable hHeaderEntries
The hashtable of the headers. keys used are types, values are HeaderEntry Objects

CRLF

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

FIELD_SEPARATOR

public static final java.lang.String FIELD_SEPARATOR
The Field separator
Constructor Detail

Header

public Header()
Create a new empty Header

Header

public Header(java.io.DataInputStream in)
       throws java.io.IOException
Create a new Header where entries are read from a given stream
Method Detail

read

public void read(java.io.DataInputStream in)
          throws java.io.IOException
Read in this header from the given Stream. Read entries are merged with existing ones.
Parameters:
in - the Stream to read the header from.

read

public void read(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.

toString

public java.lang.String toString()
Get the text value of this header
Overrides:
toString in class java.lang.Object
Returns:
a String describing this Header.

getHeaderEntryValue

public java.lang.String getHeaderEntryValue(java.lang.String type)
get the value of header type
Parameters:
type - the HeaderEntry were intrested in.
Returns:
the value of type or null if no value is set.

setHeaderEntry

public void setHeaderEntry(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

removeHeaderEntry

public void removeHeaderEntry(java.lang.String type)
removes a headerline from this header
Parameters:
type - the type we want to remove