be.re.net
Class Headers

java.lang.Object
  extended by be.re.net.Headers

public class Headers
extends Object

Several Internet protocols use headers. This class can be used to manage them. Headers can occur more than once. Even name/value pairs may be dupplicated.

Author:
Werner Donné

Nested Class Summary
 class Headers.Header
          Represents one header.
 
Constructor Summary
Headers()
           
 
Method Summary
 void add(Headers headers)
          Adds all the headers in headers.
 void add(String name, String value)
          Adds a name/value pair.
 void clear()
          Removes all headers.
 String[] get(String name)
          Returns all the values for the header name in the order of appearance.
 Headers.Header[] getAll()
          Returns all headers.
 String[] getValuesFromList(String name)
          Returns all the values for the header name in the order of appearance.
 void remove(String name)
          Removes all headers with name as their name.
 void remove(String name, String value)
          Removes one name/value pair.
 void set(String name, String value)
          Replaces all the headers with name as their name with the given name/value pair.
 void set(String name, String oldValue, String newValue)
          Replaces one name/value pair.
 int size()
          Returns the number of headers.
 String toString()
          A string representation of all headers.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Headers

public Headers()
Method Detail

add

public void add(String name,
                String value)
Adds a name/value pair.


add

public void add(Headers headers)
Adds all the headers in headers.


clear

public void clear()
Removes all headers.


get

public String[] get(String name)
Returns all the values for the header name in the order of appearance.


getAll

public Headers.Header[] getAll()
Returns all headers.


getValuesFromList

public String[] getValuesFromList(String name)
Returns all the values for the header name in the order of appearance. If a header value is a comma-separated list, the elements in the list are added separately in the order of appearance and without surrounding whitespace.


remove

public void remove(String name)
Removes all headers with name as their name.


remove

public void remove(String name,
                   String value)
Removes one name/value pair.


set

public void set(String name,
                String value)
Replaces all the headers with name as their name with the given name/value pair.


set

public void set(String name,
                String oldValue,
                String newValue)
Replaces one name/value pair.


size

public int size()
Returns the number of headers.


toString

public String toString()
A string representation of all headers. The string can be used in Internet protocols.

Overrides:
toString in class Object