Top Description Constructors Methods
org.eclipse.jetty.util

public Class MultiMap<V>

extends LinkedHashMap<String, List<V>>
Class Inheritance
Annotations
@SuppressWarnings:serial
Type Parameters
<V>
the entry type for multimap values
Imports
java.util.ArrayList, .Arrays, .Iterator, .LinkedHashMap, .List, .Map

A multi valued Map.

Constructor Summary

AccessConstructor and Description
public
public
MultiMap(Map<String, List<V>> map)

public

Method Summary

Modifier and TypeMethod and Description
public void
add(String
The entry key.
name
,
V
The entry value.
value
)

Add value to multi valued entry.

public boolean

Returns:

true if an existing key was merged with potentially new values, false if either no change was made, or there were only new keys.
addAllValues
(MultiMap<V>
the map to overlay on top of this one, merging together values if needed.
map
)

Merge values.

public void
addValues(String
The entry key.
name
,
List<V>
The List of multiple values.
values
)

Add values to multi valued entry.

public void
addValues(String
The entry key.
name
,
V[]
The String array of multiple values.
values
)

Add values to multi valued entry.

public boolean

Returns:

true if contains simple value
containsSimpleValue
(V
the value to search for
value
)

Test for a specific single value in the map.

public String

Returns:

String value.
getString
(String
The entry key.
name
)

Get value as String.

public V

Returns:

a value from index 0.
getValue
(String
The entry key.
name
)

Get the first value from a multiple value.

public V

Returns:

a value.
getValue
(String
The entry key.
name
,
int
Index of element to get.
i
)

Get a value from a multiple value.

public List<V>

Returns:

Unmodifieable List of values.
getValues
(String
The entry key.
name
)

Get multiple values.

public List<V>

Returns:

The previous value or null.
put
(String
The entry key.
name
,
V
The simple value
value
)

Overrides java.util.HashMap.put.

Implements java.util.Map.put.

Put multi valued entry.

public void
putAllValues(Map<String, V>
the input map
input
)

Shorthand version of putAll

public List<V>

Returns:

The previous value or null.
putValues
(String
The entry key.
name
,
List<V>
The List of multiple values.
values
)

Put multi valued entry.

public final List<V>

Returns:

The previous value or null.
putValues
(String
The entry key.
name
,
V...
The array of multiple values.
values
)

Put multi valued entry.

public boolean

Returns:

true if it was removed.
removeValue
(String
The entry key.
name
,
V
The entry value.
value
)

Remove value.

public String
toString()

Overrides java.util.AbstractMap.toString.

Returns a string representation of this map.

public Map<String, String[]>
toStringArrayMap()

Returns: Map of String arrays

Inherited from java.util.LinkedHashMap:
clearcontainsValueentrySetforEachgetgetOrDefaultkeySetnewLinkedHashMapputFirstputLastremoveEldestEntryreplaceAllreversedsequencedEntrySetsequencedKeySetsequencedValuesvalues

Constructor Detail

MultiMapback to summary
public MultiMap()
MultiMapback to summary
public MultiMap(Map<String, List<V>> map)
MultiMapback to summary
public MultiMap(MultiMap<V> map)

Method Detail

addback to summary
public void add(String name, V value)

Add value to multi valued entry. If the entry is single valued, it is converted to the first value of a multi valued entry.

Parameters
name:String

The entry key.

value:V

The entry value.

addAllValuesback to summary
public boolean addAllValues(MultiMap<V> map)

Merge values.

Parameters
map:MultiMap<V>

the map to overlay on top of this one, merging together values if needed.

Returns:boolean

true if an existing key was merged with potentially new values, false if either no change was made, or there were only new keys.

addValuesback to summary
public void addValues(String name, List<V> values)

Add values to multi valued entry. If the entry is single valued, it is converted to the first value of a multi valued entry.

Parameters
name:String

The entry key.

values:List<V>

The List of multiple values.

addValuesback to summary
public void addValues(String name, V[] values)

Add values to multi valued entry. If the entry is single valued, it is converted to the first value of a multi valued entry.

Parameters
name:String

The entry key.

values:V[]

The String array of multiple values.

containsSimpleValueback to summary
public boolean containsSimpleValue(V value)

Test for a specific single value in the map.

Note

This is a SLOW operation, and is actively discouraged.

Parameters
value:V

the value to search for

Returns:boolean

true if contains simple value

getStringback to summary
public String getString(String name)

Get value as String. Single valued items are converted to a String with the toString() Object method. Multi valued entries are converted to a comma separated List. No quoting of commas within values is performed.

Parameters
name:String

The entry key.

Returns:String

String value.

getValueback to summary
public V getValue(String name)

Get the first value from a multiple value.

Parameters
name:String

The entry key.

Returns:V

a value from index 0.

getValueback to summary
public V getValue(String name, int i)

Get a value from a multiple value. If the value is not a multivalue, then index 0 retrieves the value or null.

Parameters
name:String

The entry key.

i:int

Index of element to get.

Returns:V

a value.

getValuesback to summary
public List<V> getValues(String name)

Get multiple values. Single valued entries are converted to singleton lists.

Parameters
name:String

The entry key.

Returns:List<V>

Unmodifieable List of values.

putback to summary
public List<V> put(String name, V value)

Overrides java.util.HashMap.put.

Implements java.util.Map.put.

Put multi valued entry.

Parameters
name:String

The entry key.

value:V

The simple value

Returns:List<V>

The previous value or null.

putAllValuesback to summary
public void putAllValues(Map<String, V> input)

Shorthand version of putAll

Parameters
input:Map<String, V>

the input map

putValuesback to summary
public List<V> putValues(String name, List<V> values)

Put multi valued entry.

Parameters
name:String

The entry key.

values:List<V>

The List of multiple values.

Returns:List<V>

The previous value or null.

putValuesback to summary
public final List<V> putValues(String name, V... values)

Put multi valued entry.

Parameters
name:String

The entry key.

values:V[]

The array of multiple values.

Returns:List<V>

The previous value or null.

Annotations
@SafeVarargs
removeValueback to summary
public boolean removeValue(String name, V value)

Remove value.

Parameters
name:String

The entry key.

value:V

The entry value.

Returns:boolean

true if it was removed.

toStringback to summary
public String toString()

Overrides java.util.AbstractMap.toString.

Doc from java.util.AbstractMap.toString.

Returns a string representation of this map. The string representation consists of a list of key-value mappings in the order returned by the map's entrySet view's iterator, enclosed in braces ("{}"). Adjacent mappings are separated by the characters ", " (comma and space). Each key-value mapping is rendered as the key followed by an equals sign ("=") followed by the associated value. Keys and values are converted to strings as by String#valueOf(Object).

Returns:String

a string representation of this map

Annotations
@Override
toStringArrayMapback to summary
public Map<String, String[]> toStringArrayMap()
Returns:Map<String, String[]>

Map of String arrays