Package org.jibx.binding.util
Class MultipleValueMap
java.lang.Object
org.jibx.binding.util.MultipleValueMap
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 ClassesModifier and TypeClassDescriptionclass
Iterator for only the multiple-valued keys in the map.private static class
List used for multiple values. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final HashMap
Backing map from key to value or array of values.private Object
Last lookup key (null
if none, or if value changed).private Object
Last lookup value (null
if none, or if value changed).private int
Actual number of values (not keys) present in map. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add value for key.void
clear()
Clear all entries.boolean
containsKey
(Object key) Check key present in map.Extract all values for key.Get all values for key.Get indexed value for key.int
Get number of values present for key.private Object
Internal cached lookup.boolean
isEmpty()
Check if map is empty.keySet()
Get key set.int
keySize()
Get number of keys.Get iterator over only the multiple-valued keys present in the map.int
Get number of values.
-
Field Details
-
m_backingMap
Backing map from key to value or array of values. -
m_valueCount
private int m_valueCountActual number of values (not keys) present in map. -
m_lastKey
Last lookup key (null
if none, or if value changed). -
m_lastValue
Last lookup value (null
if none, or if value changed).
-
-
Constructor Details
-
MultipleValueMap
public MultipleValueMap()Constructor.
-
-
Method Details
-
getMapped
Internal cached lookup.- Parameters:
key
-- Returns:
- value
-
clear
public void clear()Clear all entries. -
getCount
Get number of values present for key.- Parameters:
key
-- Returns:
- value count
-
get
Get indexed value for key.- Parameters:
key
-index
-- Returns:
- value
-
add
Add value for key.- Parameters:
key
-value
-
-
get
Get all values for key. This returns the value(s) from the map and returns them in the form of a list.- Parameters:
key
-- Returns:
- list of values
-
extract
Extract all values for key. This removes the value(s) from the map and returns them in the form of a list.- Parameters:
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
Get iterator over only the multiple-valued keys present in the map.- Returns:
- iterator
-
containsKey
Check key present in map.- Parameters:
key
-- Returns:
- key present flag
-
isEmpty
public boolean isEmpty()Check if map is empty.- Returns:
- empty flag
-
keySet
Get key set.- Returns:
- set of keys
-