com.ning.http.client
Class FluentCaseInsensitiveStringsMap

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

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

An implementation of a String -> List<String> map that adds a fluent interface, i.e. methods that return this instance. This class differs from FluentStringsMap in that keys are treated in an case-insensitive matter, i.e. case of the key doesn't matter when retrieving values or changing the map. However, the map preserves the key case (of the first insert or replace) and returns the keys in their original case in the appropriate methods (e.g. keySet()).


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
FluentCaseInsensitiveStringsMap()
           
FluentCaseInsensitiveStringsMap(FluentCaseInsensitiveStringsMap src)
           
FluentCaseInsensitiveStringsMap(Map<String,Collection<String>> src)
           
 
Method Summary
 FluentCaseInsensitiveStringsMap add(String key, Collection<String> values)
          Adds the specified values and returns this object.
 FluentCaseInsensitiveStringsMap add(String key, String... values)
          Adds the specified values and returns this object.
 FluentCaseInsensitiveStringsMap addAll(FluentCaseInsensitiveStringsMap src)
          Adds all key-values pairs from the given object to this object and returns this object.
 FluentCaseInsensitiveStringsMap addAll(Map<String,Collection<String>> src)
          Adds all key-values pairs from the given map to this object and returns this object.
 void clear()
          
 boolean containsKey(Object key)
          
 boolean containsValue(Object value)
          
 FluentCaseInsensitiveStringsMap delete(String key)
          Removes the values for the given key if present and returns this object.
 FluentCaseInsensitiveStringsMap deleteAll(Collection<String> keys)
          Removes the values for the given keys if present and returns this object.
 FluentCaseInsensitiveStringsMap deleteAll(String... keys)
          Removes the values for the given keys if present and returns this object.
 Set<Map.Entry<String,List<String>>> entrySet()
          
 boolean equals(Object obj)
           
 List<String> get(Object key)
          
 String getFirstValue(String key)
          Returns the value for the given key.
 String getJoinedValue(String key, String delimiter)
          Returns the values for the given key joined into a single string using the given delimiter.
 int hashCode()
           
 boolean isEmpty()
          
 Iterator<Map.Entry<String,List<String>>> iterator()
          
 Set<String> keySet()
          
 List<String> put(String key, List<String> value)
          
 void putAll(Map<? extends String,? extends List<String>> values)
          
 List<String> remove(Object key)
          
 FluentCaseInsensitiveStringsMap replace(String key, Collection<String> values)
          Replaces the values for the given key with the given values.
 FluentCaseInsensitiveStringsMap replace(String key, String... values)
          Replaces the values for the given key with the given values.
 FluentCaseInsensitiveStringsMap replaceAll(FluentCaseInsensitiveStringsMap src)
          Replace the values for all keys from the given map that are also present in this object, with the values from the given map.
 FluentCaseInsensitiveStringsMap replaceAll(Map<? extends String,? extends Collection<String>> src)
          Replace the values for all keys from the given map that are also present in this object, with the values from the given map.
 int size()
          
 String toString()
           
 Collection<List<String>> values()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FluentCaseInsensitiveStringsMap

public FluentCaseInsensitiveStringsMap()

FluentCaseInsensitiveStringsMap

public FluentCaseInsensitiveStringsMap(FluentCaseInsensitiveStringsMap src)

FluentCaseInsensitiveStringsMap

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

add

public FluentCaseInsensitiveStringsMap add(String key,
                                           String... values)
Adds the specified values and returns this object.

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

add

public FluentCaseInsensitiveStringsMap add(String key,
                                           Collection<String> values)
Adds the specified values and returns this object.

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

addAll

public FluentCaseInsensitiveStringsMap addAll(FluentCaseInsensitiveStringsMap src)
Adds all key-values pairs from the given object to this object and returns this object.

Parameters:
src - The source object
Returns:
This object

addAll

public FluentCaseInsensitiveStringsMap addAll(Map<String,Collection<String>> src)
Adds all key-values pairs from the given map to this object and returns this object.

Parameters:
src - The source map
Returns:
This object

replace

public FluentCaseInsensitiveStringsMap replace(String key,
                                               String... values)
Replaces the values for the given key with the given values.

Parameters:
key - The key
values - The new values
Returns:
This object

replace

public FluentCaseInsensitiveStringsMap replace(String key,
                                               Collection<String> values)
Replaces the values for the given key with the given values.

Parameters:
key - The key
values - The new values
Returns:
This object

replaceAll

public FluentCaseInsensitiveStringsMap replaceAll(FluentCaseInsensitiveStringsMap src)
Replace the values for all keys from the given map that are also present in this object, with the values from the given map. All key-values from the given object that are not present in this object, will be added to it.

Parameters:
src - The source object
Returns:
This object

replaceAll

public FluentCaseInsensitiveStringsMap replaceAll(Map<? extends String,? extends Collection<String>> src)
Replace the values for all keys from the given map that are also present in this object, with the values from the given map. All key-values from the given object that are not present in this object, will be added to it.

Parameters:
src - The source map
Returns:
This object

put

public List<String> put(String key,
                        List<String> value)

Specified by:
put in interface Map<String,List<String>>

putAll

public void putAll(Map<? extends String,? extends List<String>> values)

Specified by:
putAll in interface Map<String,List<String>>

delete

public FluentCaseInsensitiveStringsMap delete(String key)
Removes the values for the given key if present and returns this object.

Parameters:
key - The key
Returns:
This object

deleteAll

public FluentCaseInsensitiveStringsMap deleteAll(String... keys)
Removes the values for the given keys if present and returns this object.

Parameters:
keys - The keys
Returns:
This object

deleteAll

public FluentCaseInsensitiveStringsMap deleteAll(Collection<String> keys)
Removes the values for the given keys if present and returns this object.

Parameters:
keys - The keys
Returns:
This object

remove

public List<String> remove(Object key)

Specified by:
remove in interface Map<String,List<String>>

clear

public void clear()

Specified by:
clear in interface Map<String,List<String>>

iterator

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

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

keySet

public Set<String> keySet()

Specified by:
keySet in interface Map<String,List<String>>

entrySet

public Set<Map.Entry<String,List<String>>> entrySet()

Specified by:
entrySet in interface Map<String,List<String>>

size

public int size()

Specified by:
size in interface Map<String,List<String>>

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface Map<String,List<String>>

containsKey

public boolean containsKey(Object key)

Specified by:
containsKey in interface Map<String,List<String>>

containsValue

public boolean containsValue(Object value)

Specified by:
containsValue in interface Map<String,List<String>>

getFirstValue

public String getFirstValue(String key)
Returns the value for the given key. If there are multiple values for this key, then only the first one will be returned.

Parameters:
key - The key
Returns:
The first value

getJoinedValue

public String getJoinedValue(String key,
                             String delimiter)
Returns the values for the given key joined into a single string using the given delimiter.

Parameters:
key - The key
Returns:
The value as a single string

get

public List<String> get(Object key)

Specified by:
get in interface Map<String,List<String>>

values

public Collection<List<String>> values()

Specified by:
values in interface Map<String,List<String>>

equals

public boolean equals(Object obj)
Specified by:
equals in interface Map<String,List<String>>
Overrides:
equals in class Object

hashCode

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

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.