Package org.jibx.binding.util
Class MultipleValueMap
- java.lang.Object
-
- org.jibx.binding.util.MultipleValueMap
-
public class MultipleValueMap extends Object
Map supporting multiple values for a single key. The multiple value concept doesn't really fit with the standard collections idea of a map, so this provides its own variation of a map interface rather than extend the standard one.- Author:
- Dennis M. Sosnoski
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classMultipleValueMap.MultipleIteratorIterator for only the multiple-valued keys in the map.
-
Constructor Summary
Constructors Constructor Description MultipleValueMap()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Object key, Object value)Add value for key.voidclear()Clear all entries.booleancontainsKey(Object key)Check key present in map.ArrayListextract(Object key)Extract all values for key.ArrayListget(Object key)Get all values for key.Objectget(Object key, int index)Get indexed value for key.intgetCount(Object key)Get number of values present for key.booleanisEmpty()Check if map is empty.SetkeySet()Get key set.intkeySize()Get number of keys.IteratormultipleIterator()Get iterator over only the multiple-valued keys present in the map.intvalueSize()Get number of values.
-
-
-
Method Detail
-
clear
public void clear()
Clear all entries.
-
getCount
public int getCount(Object key)
Get number of values present for key.- Parameters:
key- Key- Returns:
- value count
-
get
public Object get(Object key, int index)
Get indexed value for key.- Parameters:
key- Keyindex- Index- Returns:
- value
-
add
public void add(Object key, Object value)
Add value for key.- Parameters:
key- Keyvalue- Value
-
get
public ArrayList get(Object key)
Get all values for key. This returns the value(s) from the map and returns them in the form of a list.- Parameters:
key- Key- Returns:
- list of values
-
extract
public ArrayList extract(Object key)
Extract all values for key. This removes the value(s) from the map and returns them in the form of a list.- Parameters:
key- Key- Returns:
- prior list of values
-
keySize
public int keySize()
Get number of keys.- Returns:
- key count
-
valueSize
public int valueSize()
Get number of values.- Returns:
- value count
-
multipleIterator
public Iterator multipleIterator()
Get iterator over only the multiple-valued keys present in the map.- Returns:
- iterator
-
containsKey
public boolean containsKey(Object key)
Check key present in map.- Parameters:
key- Key- Returns:
- key present flag
-
isEmpty
public boolean isEmpty()
Check if map is empty.- Returns:
- empty flag
-
keySet
public Set keySet()
Get key set.- Returns:
- set of keys
-
-