org.mortbay.util
Class MultiMap
HashMaporg.mortbay.util.MultiMap
- Cloneable
public class MultiMap
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
$Id: MultiMap.java,v 1.18 2004/12/15 02:13:51 gregwilkins Exp $
void | 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.
|
Object | clone()
|
Object | get(Object name)
|
String | getString(Object name)- Get value as String.
|
Object | getValue(Object name, int i)- Get a value from a multiple value.
|
List | getValues(Object name)- Get multiple values.
|
Object | put(Object name, Object value)- Put and 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 | removeValue(Object name, Object value)- Remove value.
|
Map | toStringArrayMap()
|
MultiMap
public MultiMap()
Constructor.
MultiMap
public MultiMap(Map map)
Constructor.
MultiMap
public MultiMap(int size)
Constructor.
size - Capacity of the map
add
public void 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.
name - The entry key.value - The entry value.
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.
name - The entry key.values - The List of 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.
name - The entry key.values - The String array of multiple values.
clone
public Object clone()
get
public Object get(Object name)
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.
getValue
public Object getValue(Object 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.
name - The entry key.i - Index of element to get.
- Unmodifieable List of values.
getValues
public List getValues(Object name)
Get multiple values.
Single valued entries are converted to singleton lists.
- Unmodifieable List of values.
put
public Object put(Object name,
Object value)Put and entry into the map.
name - The entry key.value - The entry value.
- The previous value or null.
putAll
public void putAll(Map m)
Put all contents of map.
putValues
public Object putValues(Object name,
List values)Put multi valued entry.
name - The entry key.values - The List of multiple values.
- The previous value or null.
putValues
public Object putValues(Object name,
String[] values)Put multi valued entry.
name - The entry key.values - The String array of multiple values.
- The previous value or null.
removeValue
public boolean removeValue(Object name,
Object value)Remove value.
name - The entry key.value - The entry value.
toStringArrayMap
public Map toStringArrayMap()
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.