com.sun.xml.ws.transport.httpspi.servlet
Class Headers

java.lang.Object
  extended by com.sun.xml.ws.transport.httpspi.servlet.Headers
All Implemented Interfaces:
java.util.Map<java.lang.String,java.util.List<java.lang.String>>

public class Headers
extends java.lang.Object
implements java.util.Map<java.lang.String,java.util.List<java.lang.String>>

HTTP request and response headers are represented by this class which implements the interface Map< String,List<String>>. The keys are case-insensitive Strings representing the header names and the value associated with each key is a List<String> with one element for each occurence of the header name in the request or response.

For example, if a response header instance contains one key "HeaderName" with two values "value1 and value2" then this object is output as two header lines:

 HeaderName: value1
 HeaderName: value2
 

All the normal Map methods are provided, but the following additional convenience methods are most likely to be used:

All methods in this class accept null values for keys and values. However, null keys will never will be present in HTTP request headers, and will not be output/sent in response headers. Null values can be represented as either a null entry for the key (i.e. the list is null) or where the key has a list, but one (or more) of the list's values is null. Null values are output as a header line containing the key but no associated value.

Since:
1.6

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
Headers()
           
 
Method Summary
 void add(java.lang.String key, java.lang.String value)
          adds the given value to the list of headers for the given key.
 void clear()
           
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set<java.util.Map.Entry<java.lang.String,java.util.List<java.lang.String>>> entrySet()
           
 boolean equals(java.lang.Object o)
           
 java.util.List<java.lang.String> get(java.lang.Object key)
           
 java.lang.String getFirst(java.lang.String key)
          returns the first value from the List of String values for the given key (if at least one exists).
 int hashCode()
           
 boolean isEmpty()
           
 java.util.Set<java.lang.String> keySet()
           
 java.util.List<java.lang.String> put(java.lang.String key, java.util.List<java.lang.String> value)
           
 void putAll(java.util.Map<? extends java.lang.String,? extends java.util.List<java.lang.String>> t)
           
 java.util.List<java.lang.String> remove(java.lang.Object key)
           
 void set(java.lang.String key, java.lang.String value)
          sets the given value as the sole header value for the given key.
 int size()
           
 java.lang.String toString()
           
 java.util.Collection<java.util.List<java.lang.String>> values()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Headers

public Headers()
Method Detail

size

public int size()
Specified by:
size in interface java.util.Map<java.lang.String,java.util.List<java.lang.String>>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map<java.lang.String,java.util.List<java.lang.String>>

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map<java.lang.String,java.util.List<java.lang.String>>

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map<java.lang.String,java.util.List<java.lang.String>>

get

public java.util.List<java.lang.String> get(java.lang.Object key)
Specified by:
get in interface java.util.Map<java.lang.String,java.util.List<java.lang.String>>

getFirst

public java.lang.String getFirst(java.lang.String key)
returns the first value from the List of String values for the given key (if at least one exists).

Parameters:
key - the key to search for
Returns:
the first string value associated with the key

put

public java.util.List<java.lang.String> put(java.lang.String key,
                                            java.util.List<java.lang.String> value)
Specified by:
put in interface java.util.Map<java.lang.String,java.util.List<java.lang.String>>

add

public void add(java.lang.String key,
                java.lang.String value)
adds the given value to the list of headers for the given key. If the mapping does not already exist, then it is created

Parameters:
key - the header name
value - the header value to add to the header

set

public void set(java.lang.String key,
                java.lang.String value)
sets the given value as the sole header value for the given key. If the mapping does not already exist, then it is created

Parameters:
key - the header name
value - the header value to set.

remove

public java.util.List<java.lang.String> remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map<java.lang.String,java.util.List<java.lang.String>>

putAll

public void putAll(java.util.Map<? extends java.lang.String,? extends java.util.List<java.lang.String>> t)
Specified by:
putAll in interface java.util.Map<java.lang.String,java.util.List<java.lang.String>>

clear

public void clear()
Specified by:
clear in interface java.util.Map<java.lang.String,java.util.List<java.lang.String>>

keySet

public java.util.Set<java.lang.String> keySet()
Specified by:
keySet in interface java.util.Map<java.lang.String,java.util.List<java.lang.String>>

values

public java.util.Collection<java.util.List<java.lang.String>> values()
Specified by:
values in interface java.util.Map<java.lang.String,java.util.List<java.lang.String>>

entrySet

public java.util.Set<java.util.Map.Entry<java.lang.String,java.util.List<java.lang.String>>> entrySet()
Specified by:
entrySet in interface java.util.Map<java.lang.String,java.util.List<java.lang.String>>

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Map<java.lang.String,java.util.List<java.lang.String>>
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Map<java.lang.String,java.util.List<java.lang.String>>
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.