From c68769cf7f6294cac9b793a58c8917cfbd9a51c5 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Thu, 13 Mar 2014 13:57:10 +0000 Subject: [PATCH] MultiMap: Cleanups, javadocs after review --- .../src/src/org/mortbay/util/MultiMap.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/apps/susimail/src/src/org/mortbay/util/MultiMap.java b/apps/susimail/src/src/org/mortbay/util/MultiMap.java index 2a16cf5206..62bcbb7880 100644 --- a/apps/susimail/src/src/org/mortbay/util/MultiMap.java +++ b/apps/susimail/src/src/org/mortbay/util/MultiMap.java @@ -5,13 +5,23 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; +/** + * A multi valued Map. + * Simple I2P replacement for org.eclipse.jetty.util.MultiMap + * so we don't depend on Jetty utils. + * + * Contains only the methods required by MultiPartRequest. + * Does not implement Map. Unsynchronized. + * + * @since 0.9.12 + */ public class MultiMap<T> { - HashMap<T, LinkedList<Object>> data; + private final HashMap<T, LinkedList<Object>> data; - public MultiMap(int i) + public MultiMap(int capacity) { - data = new HashMap<T, LinkedList<Object>>(); + data = new HashMap<T, LinkedList<Object>>(capacity); } public Set<T> keySet() @@ -19,6 +29,14 @@ public class MultiMap<T> return data.keySet(); } + /** + * This returns the first item or null. + * The Jetty version appears to return the item if only one, + * or the entire list if more than one. + * Only used by MultiPartRequest.contains() which is unused. + * contains() would fail with a ClassCastException if we returned a list here, + * which is a bug in MultiPartRequest? + */ public Object get(T key) { List<Object> tmp = getValues(key); -- GitLab