com.ning.http.client
Class FluentStringsMap

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

public class FluentStringsMap
extends java.lang.Object
implements java.util.Map<java.lang.String,java.util.List<java.lang.String>>, java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.util.List<java.lang.String>>>

An implementation of a String -> List<String> map that adds a fluent interface, i.e. methods that return this instance.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
FluentStringsMap()
           
FluentStringsMap(FluentStringsMap src)
           
FluentStringsMap(java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> src)
           
 
Method Summary
 FluentStringsMap add(java.lang.String key, java.util.Collection<java.lang.String> values)
          Adds the specified values and returns this object.
 FluentStringsMap add(java.lang.String key, java.lang.String... values)
          Adds the specified values and returns this object.
 FluentStringsMap addAll(FluentStringsMap src)
          Adds all key-values pairs from the given object to this object and returns this object.
 FluentStringsMap addAll(java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> src)
          Adds all key-values pairs from the given map to this object and returns this object.
 void clear()
          
 boolean containsKey(java.lang.Object key)
          
 boolean containsValue(java.lang.Object value)
          
 FluentStringsMap delete(java.lang.String key)
          Removes the values for the given key if present and returns this object.
 FluentStringsMap deleteAll(java.util.Collection<java.lang.String> keys)
          Removes the values for the given keys if present and returns this object.
 FluentStringsMap deleteAll(java.lang.String... keys)
          Removes the values for the given keys if present and returns this object.
 java.util.Set<java.util.Map.Entry<java.lang.String,java.util.List<java.lang.String>>> entrySet()
          
 boolean equals(java.lang.Object obj)
           
 java.util.List<java.lang.String> get(java.lang.Object key)
          
 java.lang.String getFirstValue(java.lang.String key)
          Returns the value for the given key.
 java.lang.String getJoinedValue(java.lang.String key, java.lang.String delimiter)
          Returns the values for the given key joined into a single string using the given delimiter.
 int hashCode()
           
 boolean isEmpty()
          
 java.util.Iterator<java.util.Map.Entry<java.lang.String,java.util.List<java.lang.String>>> iterator()
          
 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>> values)
          
 java.util.List<java.lang.String> remove(java.lang.Object key)
          
 FluentStringsMap replace(java.lang.String key, java.util.Collection<java.lang.String> values)
          Replaces the values for the given key with the given values.
 FluentStringsMap replace(java.lang.String key, java.lang.String... values)
          Replaces the values for the given key with the given values.
 FluentStringsMap replaceAll(FluentStringsMap 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.
 FluentStringsMap replaceAll(java.util.Map<? extends java.lang.String,? extends java.util.Collection<java.lang.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()
          
 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

FluentStringsMap

public FluentStringsMap()

FluentStringsMap

public FluentStringsMap(FluentStringsMap src)

FluentStringsMap

public FluentStringsMap(java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> src)
Method Detail

add

public FluentStringsMap add(java.lang.String key,
                            java.lang.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 FluentStringsMap add(java.lang.String key,
                            java.util.Collection<java.lang.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 FluentStringsMap addAll(FluentStringsMap 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 FluentStringsMap addAll(java.util.Map<java.lang.String,java.util.Collection<java.lang.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 FluentStringsMap replace(java.lang.String key,
                                java.lang.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 FluentStringsMap replace(java.lang.String key,
                                java.util.Collection<java.lang.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 FluentStringsMap replaceAll(FluentStringsMap 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 FluentStringsMap replaceAll(java.util.Map<? extends java.lang.String,? extends java.util.Collection<java.lang.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 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>>

putAll

public void putAll(java.util.Map<? extends java.lang.String,? extends java.util.List<java.lang.String>> values)

Specified by:
putAll in interface java.util.Map<java.lang.String,java.util.List<java.lang.String>>

delete

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

Parameters:
key - The key
Returns:
This object

deleteAll

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

Parameters:
keys - The keys
Returns:
This object

deleteAll

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

Parameters:
keys - The keys
Returns:
This object

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>>

clear

public void clear()

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

iterator

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

Specified by:
iterator in interface java.lang.Iterable<java.util.Map.Entry<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>>

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>>

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>>

getFirstValue

public java.lang.String getFirstValue(java.lang.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 java.lang.String getJoinedValue(java.lang.String key,
                                       java.lang.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 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>>

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>>

equals

public boolean equals(java.lang.Object obj)
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 © 2011. All Rights Reserved.