There's really not much difference between using:

Map results = new HashMap(map);

and:

Map results = new HashMap();
results.putAll(map);

Maybe I'm missing the point you're trying to make, but I don't see how that
would solve the problem.

Quoting Ron Grabowski <[EMAIL PROTECTED]>:

> > Date: Tue,  8 Jun 2004 15:42:58 -0400
> > From: Kris Schneider <[EMAIL PROTECTED]>
> > To: Struts Users Mailing List
> > <[EMAIL PROTECTED]>
> > Subject: Re: html:link and map of request parameters
> > 
> > I believe the base requirement for Struts 1.1 is JDK
> > 1.2 or later. Since
> > LinkedHashMap was introduced in JDK 1.4, it really
> > can't be used in the Struts
> > codebase. I suppose
> > org.apache.commons.collections.SequencedHashMap
> > could be
> > used in its place. However, the problem is really
> > more general than that. What
> > if someone was using a SortedMap? Or a WeakHashMap?
> > Or SomeOtherSpecialMap? The
> > process of doing:
> > 
> > results = new HashMap(map);
> > 
> > blows away any special functionality that might
> > impact how the original map
> > makes entries available. I'm not exactly sure why
> > the entries are copied out of
> > the original map, but it may have something to do
> > with trying to avoid raising
> > a ConcurrentModificationException.
> 
> The java.util.Map interface has a putAll(Map m)
> method. If that were called instead of new Hashmap():
> 
>  results.putAll(map);
> 
> results would still get populated. SortedMap,
> WeakHashMap, SomeOtherSpecialMap, etc. all implement
> the Map interface so those should continue to work.
> 
> The documentation calls for a java.util.Map object,
> why not call a java.util.Map method?
> 
> - Ron

-- 
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to