JIDE 3.5.15

com.jidesoft.grid
Class MultiValuedMap

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap
          extended by com.jidesoft.grid.MultiValuedMap
All Implemented Interfaces:
Serializable, Cloneable, Map

public class MultiValuedMap
extends HashMap
implements Cloneable

A multi valued Map. This Map specializes HashMap and provides methods that operate on multi valued items.

Implemented as a map of LazyList values

Author:
Greg Wilkins (gregw)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
MultiValuedMap()
          Constructor.
MultiValuedMap(int size)
          Constructor.
MultiValuedMap(Map map)
          Constructor.
 
Method Summary
 List add(Object name, Object value)
          Add value to multi valued entry.
 void addValues(Object name, List values)
          Add values to multi valued entry.
 void addValues(Object name, String[] values)
          Add values to multi valued entry.
 void change(Object name, Object oldValue, Object newValue)
          Remove value.
 MultiValuedMap clone()
           
 Object get(Object name)
           
 Object get(Object name, int index)
          Get a value from a multiple value.
 Object getRaw(Object name)
           
 String getString(Object name)
          Get value as String.
 List getValues(Object name)
          Get multiple values.
static boolean isSorted()
           
 Object put(Object name, Object value)
          Put an entry into the map.
 void putAll(Map m)
          Put all contents of map.
 Object putValues(Object name, List values)
          Put multi valued entry.
 Object putValues(Object name, String[] values)
          Put multi valued entry.
 boolean remove(Object name, Object value)
          Remove value.
static void setSorted(boolean sorted)
           
 Map toStringArrayMap()
           
 
Methods inherited from class java.util.HashMap
clear, containsKey, containsValue, entrySet, isEmpty, keySet, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

MultiValuedMap

public MultiValuedMap()
Constructor.


MultiValuedMap

public MultiValuedMap(int size)
Constructor.

Parameters:
size - Capacity of the map

MultiValuedMap

public MultiValuedMap(Map map)
Constructor.

Parameters:
map -
Method Detail

getValues

public List getValues(Object name)
Get multiple values. Single valued entries are converted to singleton lists.

Parameters:
name - The entry key.
Returns:
Unmodifiable List of values.

get

public Object get(Object name,
                  int index)
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.
index - Index of element to get.
Returns:
Unmodifiable List of values.

getString

public String getString(Object 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 - The entry key.
Returns:
String value.

get

public Object get(Object name)
Specified by:
get in interface Map
Overrides:
get in class HashMap

getRaw

public Object getRaw(Object name)

put

public Object put(Object name,
                  Object value)
Put an entry into the map.

Specified by:
put in interface Map
Overrides:
put in class HashMap
Parameters:
name - The entry key.
value - The entry value.
Returns:
The previous value or null.

putValues

public Object putValues(Object name,
                        List values)
Put multi valued entry.

Parameters:
name - The entry key.
values - The entry multiple values.
Returns:
The previous value or null.

putValues

public Object putValues(Object name,
                        String[] values)
Put multi valued entry.

Parameters:
name - The entry key.
values - The entry multiple values.
Returns:
The previous value or null.

add

public List add(Object name,
                Object 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 - The entry key.
value - The entry value.
Returns:
the list of values

addValues

public void addValues(Object name,
                      List 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 - The entry key.
values - The entry multiple values.

addValues

public void addValues(Object name,
                      String[] 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 - The entry key.
values - The entry multiple values.

remove

public boolean remove(Object name,
                      Object value)
Remove value.

Parameters:
name - The entry key.
value - The entry value.
Returns:
true if it was removed.

change

public void change(Object name,
                   Object oldValue,
                   Object newValue)
Remove value.

Parameters:
name - The entry key.
oldValue - The entry value.

putAll

public void putAll(Map m)
Put all contents of map.

Specified by:
putAll in interface Map
Overrides:
putAll in class HashMap
Parameters:
m - Map

toStringArrayMap

public Map toStringArrayMap()
Returns:
Map of String arrays

clone

public MultiValuedMap clone()
Overrides:
clone in class HashMap

setSorted

public static void setSorted(boolean sorted)

isSorted

public static boolean isSorted()

JIDE 3.5.15