net.sf.saffron.util
Class MultiMap

java.lang.Object
  |
  +--java.util.AbstractMap
        |
        +--java.util.HashMap
              |
              +--net.sf.saffron.util.MultiMap
All Implemented Interfaces:
Cloneable, Map, Serializable

public class MultiMap
extends HashMap

Map which contains more than one value per key.

You can either use a MultiMap as a regular map, or you can use the additional methods putMulti(java.lang.Object, java.lang.Object) and getMulti(java.lang.Object). Values are returned in the order in which they were added.

Since:
May 18, 2003
Version:
$Id: //open/saffron/src/net/sf/saffron/util/MultiMap.java#2 $
Author:
jhyde
See Also:
Serialized Form

Nested Class Summary
private static class MultiMap.ValueList
          Holder class, ensures that user's values are never interpreted as multiple values.
 
Field Summary
 
Fields inherited from class java.util.HashMap
 
Fields inherited from class java.util.AbstractMap
 
Constructor Summary
MultiMap()
           
 
Method Summary
 List getMulti(Object key)
          Returns a list of values for a given key; returns an empty list if not found.
 void putMulti(Object key, Object value)
          Adds a value for this key.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, 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

MultiMap

public MultiMap()
Method Detail

getMulti

public List getMulti(Object key)
Returns a list of values for a given key; returns an empty list if not found.

Post-condition:
return != null

putMulti

public void putMulti(Object key,
                     Object value)
Adds a value for this key.


SourceForge.net_Logo