com.ning.http.client
Class Headers

java.lang.Object
  extended by com.ning.http.client.Headers
All Implemented Interfaces:
Iterable<Map.Entry<String,List<String>>>

public class Headers
extends Object
implements Iterable<Map.Entry<String,List<String>>>


Constructor Summary
Headers()
           
Headers(Headers src)
           
Headers(Map<String,Collection<String>> src)
           
 
Method Summary
 Headers add(String name, Collection<String> values)
          Adds the specified header values and returns this headers object.
 Headers add(String name, String... values)
          Adds the specified header and returns this headers object.
 Headers addAll(Headers src)
          Adds all headers from the given headers object to this object and returns this headers object.
 Headers addAll(Map<String,Collection<String>> src)
          Adds all headers from the given map to this object and returns this headers object.
 boolean equals(Object obj)
           
 String getFirstHeaderValue(String name)
          Returns the (first) value of the header of the given name.
 Set<String> getHeaderNames()
          Returns the names of all defined headers.
 String getHeaderValue(String name)
          Returns the value of the header of the given name.
 List<String> getHeaderValues(String name)
          Returns all defined values for the specified header.
 int hashCode()
           
 boolean isDefined(String name)
          Determines whether the indicated header is defined.
 Iterator<Map.Entry<String,List<String>>> iterator()
          
 Headers remove(String name)
          Removes the specified header if present and returns this headers object.
 Headers removeAll(Collection<String> names)
          Removed all specified headers in this object and returns this headers object.
 Headers removeAll(String... names)
          Removed all specified headers in this object and returns this headers object.
 Headers replace(String name, Collection<String> values)
          Replaces the indicated header with the given values.
 Headers replace(String name, String... values)
          Replaces the indicated header with the given values.
 Headers replaceAll(Headers src)
          Replaces all headers present the given headers object in this object and returns this headers object.
 Headers replaceAll(Map<String,Collection<String>> src)
          Replaces all headers from the given map in this object and returns this headers object.
 String toString()
           
static Headers unmodifiableHeaders(Headers headers)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Headers

public Headers()

Headers

public Headers(Headers src)

Headers

public Headers(Map<String,Collection<String>> src)
Method Detail

unmodifiableHeaders

public static Headers unmodifiableHeaders(Headers headers)

add

public Headers add(String name,
                   String... values)
Adds the specified header and returns this headers object.

Parameters:
name - The header name
values - The header value; if null then this method has no effect. Use the empty string to generate an empty header value
Returns:
This object

add

public Headers add(String name,
                   Collection<String> values)
Adds the specified header values and returns this headers object.

Parameters:
name - The header name
values - The header values; if null then this method has no effect. Use an empty collection to generate an empty header value
Returns:
This object

addAll

public Headers addAll(Headers src)
Adds all headers from the given headers object to this object and returns this headers object.

Parameters:
src - The source headers object
Returns:
This object

addAll

public Headers addAll(Map<String,Collection<String>> src)
Adds all headers from the given map to this object and returns this headers object.

Parameters:
src - The source map of headers
Returns:
This object

replace

public Headers replace(String name,
                       String... values)
Replaces the indicated header with the given values.

Parameters:
name - The header name
values - The new header values
Returns:
This object

replace

public Headers replace(String name,
                       Collection<String> values)
Replaces the indicated header with the given values.

Parameters:
name - The header name
values - The new header value
Returns:
This object

replaceAll

public Headers replaceAll(Headers src)
Replaces all headers present the given headers object in this object and returns this headers object.

Parameters:
src - The source headers object
Returns:
This object

replaceAll

public Headers replaceAll(Map<String,Collection<String>> src)
Replaces all headers from the given map in this object and returns this headers object.

Parameters:
src - The source map of headers
Returns:
This object

iterator

public Iterator<Map.Entry<String,List<String>>> iterator()

Specified by:
iterator in interface Iterable<Map.Entry<String,List<String>>>

getHeaderNames

public Set<String> getHeaderNames()
Returns the names of all defined headers.

Returns:
The header names

isDefined

public boolean isDefined(String name)
Determines whether the indicated header is defined.

Parameters:
name - The header name
Returns:
true if the header is defined

getFirstHeaderValue

public String getFirstHeaderValue(String name)
Returns the (first) value of the header of the given name. If there are multiple values for that header, then the first one will be returned. This method is more appropriate for certain headers like Content-Type or Content-Length where multiple values can break servers/clients.

Parameters:
name - The header's name
Returns:
The (first) header value; null if this header is not defined

getHeaderValue

public String getHeaderValue(String name)
Returns the value of the header of the given name. If there are multiple values for that header, then they will be concatenated according to the RFC????.

Parameters:
name - The header's name
Returns:
The header value; null if this header is not defined

getHeaderValues

public List<String> getHeaderValues(String name)
Returns all defined values for the specified header.

Parameters:
name - The header name
Returns:
The values, or null if the header is not defined

remove

public Headers remove(String name)
Removes the specified header if present and returns this headers object.

Parameters:
name - The header name
Returns:
This object

removeAll

public Headers removeAll(String... names)
Removed all specified headers in this object and returns this headers object.

Parameters:
names - The header names
Returns:
This object

removeAll

public Headers removeAll(Collection<String> names)
Removed all specified headers in this object and returns this headers object.

Parameters:
names - The header names
Returns:
This object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010. All Rights Reserved.