ch.mimo.netty.handler.codec.icap
Class IcapHeaders

java.lang.Object
  extended by ch.mimo.netty.handler.codec.icap.IcapHeaders

public final class IcapHeaders
extends Object

Icap Headers This class provides a linked list implementation in order to store Icap headers.

Author:
Michael Mimo Moratti (mimo@mimo.ch)

Nested Class Summary
static class IcapHeaders.Names
          The most common Icap Header names.
 
Constructor Summary
IcapHeaders()
           
 
Method Summary
 void addDateHeader(String name, Date value)
           
 void addHeader(String name, Object value)
          Adds a header key,value combination to the list The existence of such a header name will have no impact.
 void clearHeaders()
           
 boolean containsHeader(String name)
          check method to validate if a certain header does exists in the list.
 Date getDateHeader(String name)
          retrieves a date header value as @see Date If the header does not exist null is returned.
 String getHeader(String name)
          retrieves a header value from the list.
 Set<String> getHeaderNames()
          retrieval method for all header names.
 Set<Map.Entry<String,String>> getHeaders()
          retrieval method for all headers that are currently in this list.
 Set<String> getHeaders(String name)
          retrieves all values for one header name.
 int getPreviewHeaderValue()
          Convenience method to retrieve the @see Integer value from a Icap Preview header.
 void removeHeader(String name)
          removes all headers with the same name from the list.
 void setHeader(String name, Iterable<?> values)
          Sets one header with many values.
 void setHeader(String name, Object value)
          Sets one header at the end of the list.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IcapHeaders

public IcapHeaders()
Method Detail

clearHeaders

public void clearHeaders()

addHeader

public void addHeader(String name,
                      Object value)
Adds a header key,value combination to the list The existence of such a header name will have no impact. The header is simply added to the end of the linked list.

Parameters:
name - Icap message header name
value - Icap message header value. Can also be null

addDateHeader

public void addDateHeader(String name,
                          Date value)

setHeader

public void setHeader(String name,
                      Object value)
Sets one header at the end of the list. Headers with the same name that are already in the list will be removed first!

Parameters:
name - Icap message header name
value - Icap message header value. Can also be null

setHeader

public void setHeader(String name,
                      Iterable<?> values)
Sets one header with many values. Headers with the same name that are already in the list will be removed first!

Parameters:
name - Icap message header name
values - Icap message header value. Can also be null

getHeader

public String getHeader(String name)
retrieves a header value from the list. If no header exists with the given name null is returned. If there are multiple headers with the same name only the first occurence in the list is returned.

Parameters:
name - Icap message header name
Returns:
String value or null

getDateHeader

public Date getDateHeader(String name)
retrieves a date header value as @see Date If the header does not exist null is returned. If the date cannot be parsed a parsing exception is thrown.

Parameters:
name - Icap message header name
Returns:
if possible a valid @see Date instance or null
Throws:
IllegalArgumentException - if the date string value cannot be parsed.

getHeaders

public Set<String> getHeaders(String name)
retrieves all values for one header name. If no header exists with that given name an empty set is returned.

Parameters:
name - Icap message header name
Returns:
Set of values from all headers with the same name, or empty set.

getHeaders

public Set<Map.Entry<String,String>> getHeaders()
retrieval method for all headers that are currently in this list.

Returns:
Set of Map Entry instances.

containsHeader

public boolean containsHeader(String name)
check method to validate if a certain header does exists in the list.

Parameters:
name - Icap message header name
Returns:
boolean true if the header exists.

removeHeader

public void removeHeader(String name)
removes all headers with the same name from the list.

Parameters:
name - Icap message header name

getHeaderNames

public Set<String> getHeaderNames()
retrieval method for all header names. this list is unique. If a header name has two entries the name is returned only once.

Returns:
unique set with all header names in the list.

getPreviewHeaderValue

public int getPreviewHeaderValue()
Convenience method to retrieve the @see Integer value from a Icap Preview header. If the header does not exist the value 0 is returned. If the header value cannot be parsed into a valid integer a @see IcapDecodingError is thrown.

Returns:
int value of preview header.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.