Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.mortbay.util
Class MultiMap  view MultiMap download MultiMap.java

java.lang.Object
  extended byjava.util.AbstractMap
      extended byjava.util.HashMap
          extended byorg.mortbay.util.MultiMap
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable
Direct Known Subclasses:
UrlEncoded

public class MultiMap
extends java.util.HashMap
implements java.lang.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

Version:
$Id: MultiMap.java,v 1.12 2003/07/28 00:34:45 gregwilkins Exp $

Nested Class Summary
 
Nested classes inherited from class java.util.HashMap
 
Nested classes inherited from class java.util.AbstractMap
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
 
Fields inherited from class java.util.HashMap
 
Fields inherited from class java.util.AbstractMap
 
Constructor Summary
MultiMap()
          Constructor.
MultiMap(int size)
          Constructor.
MultiMap(java.util.Map map)
          Constructor.
 
Method Summary
 void add(java.lang.Object name, java.lang.Object value)
          Add value to multi valued entry.
 void addValues(java.lang.Object name, java.util.List values)
          Add values to multi valued entry.
 void addValues(java.lang.Object name, java.lang.String[] values)
          Add values to multi valued entry.
 java.lang.Object clone()
          Returns a shallow clone of this HashMap.
 java.lang.Object get(java.lang.Object name)
          Return the value in this HashMap associated with the supplied key, or null if the key maps to nothing.
 java.lang.String getString(java.lang.Object name)
          Get value as String.
 java.lang.Object getValue(java.lang.Object name, int i)
          Get a value from a multiple value.
 java.util.List getValues(java.lang.Object name)
          Get multiple values.
 java.lang.Object put(java.lang.Object name, java.lang.Object value)
          Put and entry into the map.
 void putAll(java.util.Map m)
          Put all contents of map.
 java.lang.Object putValues(java.lang.Object name, java.util.List values)
          Put multi valued entry.
 java.lang.Object putValues(java.lang.Object name, java.lang.String[] values)
          Put multi valued entry.
 boolean removeValue(java.lang.Object name, java.lang.Object value)
          Remove value.
 java.util.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

MultiMap

public MultiMap()
Constructor.


MultiMap

public MultiMap(int size)
Constructor.


MultiMap

public MultiMap(java.util.Map map)
Constructor.

Method Detail

getValues

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


getValue

public java.lang.Object getValue(java.lang.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.


getString

public java.lang.String getString(java.lang.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.


get

public java.lang.Object get(java.lang.Object name)
Description copied from class: java.util.HashMap
Return the value in this HashMap associated with the supplied key, or null if the key maps to nothing. NOTE: Since the value could also be null, you must use containsKey to see if this key actually maps to something.

Specified by:
get in interface java.util.Map

put

public java.lang.Object put(java.lang.Object name,
                            java.lang.Object value)
Put and entry into the map.

Specified by:
put in interface java.util.Map

putValues

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


putValues

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


add

public void add(java.lang.Object name,
                java.lang.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.


addValues

public void addValues(java.lang.Object name,
                      java.util.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.


addValues

public void addValues(java.lang.Object name,
                      java.lang.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.


removeValue

public boolean removeValue(java.lang.Object name,
                           java.lang.Object value)
Remove value.


putAll

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

Specified by:
putAll in interface java.util.Map

toStringArrayMap

public java.util.Map toStringArrayMap()

clone

public java.lang.Object clone()
Description copied from class: java.util.HashMap
Returns a shallow clone of this HashMap. The Map itself is cloned, but its contents are not. This is O(n).