ice.util.net
Class HeaderMap

java.lang.Object
  extended byice.util.net.HeaderMap
All Implemented Interfaces:
Cloneable, Serializable

public class HeaderMap
extends Object
implements Cloneable, Serializable

The HeaderMap class represents a collection of HeaderMap.Headers each consisting of a field name and a field value. The HeaderMap class allows duplicate field name entries!

Since:
1.3.6
Version:
1.3.6
Author:
Jack van Ooststroom
See Also:
Serialized Form

Nested Class Summary
static class HeaderMap.Header
           
 
Constructor Summary
HeaderMap()
          Constructs an empty HeaderMap.
HeaderMap(int initialCapacity)
          Constructs an empty HeaderMap with the specified initialCapacity.
 
Method Summary
 void clear()
          Removes all the headers from this HeaderMap.
 Object clone()
           
 boolean containsFieldName(String fieldName)
          Returns true if this HeaderMap contains a mapping for the specified fieldName.
 void ensureCapacity(int minimumCapacity)
          Increases the capacity of this HeaderMap instance, if necessary, to ensure that it can hold at least the number of headers specified by the minimumCapacity argument.
 boolean equals(Object object)
           
 HeaderMap.Header get(int index)
          Returns the Header at the specified index in this HeaderMap.
 String getFieldName(int index)
          Returns the field name at the specified index in this HeaderMap.
 String getFieldValue(int index)
          Returns the field value at the specified index in this HeaderMap.
 String[] getFieldValues(String fieldName)
          Returns the field value that is mapped with the specified fieldName in this HeaderMap.
 int getSize()
          Returns the number of Headers in this HeaderMap.
 boolean isEmpty()
          Returns true if this HeaderMap contains no headers.
 void putHeader(String fieldName, String fieldValue)
          Maps the specified fieldValue with the specified fieldName in this HeaderMap.
 void putHeader(String fieldName, String fieldValue, boolean replace)
          Maps the specified fieldValue with the specified fieldName in this HeaderMap.
 void removeHeader(int index)
          Removes the mapping at the specified index from this HeaderMap if present.
 void removeHeaders(String fieldName)
          Removes all mappings for the specified fieldName from this HeaderMap if one is present.
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HeaderMap

public HeaderMap()
Constructs an empty HeaderMap.


HeaderMap

public HeaderMap(int initialCapacity)
          throws IllegalArgumentException

Constructs an empty HeaderMap with the specified initialCapacity.

Parameters:
initialCapacity - the initial capacity of the HeaderMap.
Throws:
IllegalArgumentException - if the specified initialCapacity is less than 0.
Method Detail

clear

public void clear()

Removes all the headers from this HeaderMap. This HeaderMap will be empty after this call returns.


clone

public Object clone()

containsFieldName

public boolean containsFieldName(String fieldName)

Returns true if this HeaderMap contains a mapping for the specified fieldName.

Parameters:
fieldName - field name whose presence in this HeaderMap is to be tested.
Returns:
true if this HeaderMap contains a mapping for the specified fieldName.

ensureCapacity

public void ensureCapacity(int minimumCapacity)

Increases the capacity of this HeaderMap instance, if necessary, to ensure that it can hold at least the number of headers specified by the minimumCapacity argument.

Parameters:
minimumCapacity - the desired minimum capacity.

equals

public boolean equals(Object object)

get

public HeaderMap.Header get(int index)

Returns the Header at the specified index in this HeaderMap.

Parameters:
index - the index of the Header to return.
Returns:
the Header at the specified index in this HeaderMap, or null.

getFieldName

public String getFieldName(int index)

Returns the field name at the specified index in this HeaderMap.

Parameters:
index - the index of the field name to return.
Returns:
the field name at the specified index in this HeaderMap, or null.

getFieldValue

public String getFieldValue(int index)

Returns the field value at the specified index in this HeaderMap.

Parameters:
index - the index of the field value to return.
Returns:
the field value at the specified index in this HeaderMap, or null.

getFieldValues

public String[] getFieldValues(String fieldName)

Returns the field value that is mapped with the specified fieldName in this HeaderMap.

If this HeaderMap contains more than one mapping with the specified fieldName, all the field values are returned.

Parameters:
fieldName - the field name whose mapped field value is to be returned.
Returns:
zero or more field values to which this HeaderMap maps the specified fieldName.

getSize

public int getSize()

Returns the number of Headers in this HeaderMap.

Returns:
the number of Headers in this HeaderMap.

isEmpty

public boolean isEmpty()
Returns true if this HeaderMap contains no headers.

Returns:
true if this HeaderMap contains no headers.

putHeader

public void putHeader(String fieldName,
                      String fieldValue)

Maps the specified fieldValue with the specified fieldName in this HeaderMap. If this HeaderMap previously contained a mapping for this fieldName, an additional mapping is created for the specified fieldValue.

Parameters:
fieldName - the field name with which the specified fieldValue is to be mapped.
fieldValue - the field value to be mapped with the specified fieldName.
See Also:
putHeader(String, String, boolean)

putHeader

public void putHeader(String fieldName,
                      String fieldValue,
                      boolean replace)

Maps the specified fieldValue with the specified fieldName in this HeaderMap. If the specified replace boolean equals true, any previous mappings for this fieldName will be removed, otherwise an additional mapping is created for the specified fieldValue.

Parameters:
fieldName - the field name with which the specified fieldValue is to be mapped.
fieldValue - the field value to be mapped with the specified fieldName.
replace - if set to true, this fieldName mapping replaces all previous mappings to fieldName.
Since:
1.5.1
See Also:
putHeader(String, String)

removeHeader

public void removeHeader(int index)

Removes the mapping at the specified index from this HeaderMap if present.

Parameters:
index - the index of the mapping to be removed from this HeaderMap.

removeHeaders

public void removeHeaders(String fieldName)

Removes all mappings for the specified fieldName from this HeaderMap if one is present.

Parameters:
fieldName - the field name whose mappings are to be removed from this HeaderMap.

toString

public String toString()