Package org.eclipse.jetty.util
Class MultiMap<V>
- Type Parameters:
V
- the entry type for multimap values
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<String,
List<V>>
A multi valued Map.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add value to multi valued entry.boolean
addAllValues
(MultiMap<V> map) Merge values.void
Add values to multi valued entry.void
Add values to multi valued entry.boolean
containsSimpleValue
(V value) Test for a specific single value in the map.Get value as String.Get the first value from a multiple value.Get a value from a multiple value.Get multiple values.Put multi valued entry.void
putAllValues
(Map<String, V> input) Shorthand version of putAllPut multi valued entry.Put multi valued entry.boolean
removeValue
(String name, V value) Remove value.toString()
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
Methods inherited from class java.util.AbstractMap
equals, hashCode
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
Constructor Details
-
MultiMap
public MultiMap() -
MultiMap
-
MultiMap
-
-
Method Details
-
getValues
Get multiple values. Single valued entries are converted to singleton lists.- Parameters:
name
- The entry key.- Returns:
- Unmodifieable List of values.
-
getValue
Get the first value from a multiple value.- Parameters:
name
- The entry key.- Returns:
- a value from index 0.
-
getValue
Get a value from a multiple value. If the value is not a multivalue, then index 0 retrieves the value or null.- Parameters:
name
- The entry key.i
- Index of element to get.- Returns:
- a value.
-
getString
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
- The entry key.- Returns:
- String value.
-
put
Put multi valued entry.- Parameters:
name
- The entry key.value
- The simple value- Returns:
- The previous value or null.
-
putAllValues
Shorthand version of putAll- Parameters:
input
- the input map
-
putValues
Put multi valued entry.- Parameters:
name
- The entry key.values
- The List of multiple values.- Returns:
- The previous value or null.
-
putValues
Put multi valued entry.- Parameters:
name
- The entry key.values
- The array of multiple values.- Returns:
- The previous value or null.
-
add
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
- The entry key.value
- The entry value.
-
addValues
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
- The entry key.values
- The List of multiple values.
-
addValues
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
- The entry key.values
- The String array of multiple values.
-
addAllValues
Merge values.- Parameters:
map
- the map to overlay on top of this one, merging together values if needed.- 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.
-
removeValue
Remove value.- Parameters:
name
- The entry key.value
- The entry value.- Returns:
- true if it was removed.
-
containsSimpleValue
Test for a specific single value in the map.NOTE: This is a SLOW operation, and is actively discouraged.
- Parameters:
value
- the value to search for- Returns:
- true if contains simple value
-
toString
- Overrides:
toString
in classAbstractMap<String,
List<V>>
-
toStringArrayMap
- Returns:
- Map of String arrays
-