> Update... I revisited the copying idea, and it seems to work. The first
> thing I tried was using Map.putAll() like:
>
> Map parameterMap = request.getParameterMap();
> HashMap h = new HashMap();
> parameterMap.putAll(h);
That should be
h.putAll(parameterMap);
if you want to copy the parameter map into h.
Another way to get an unlocked copy would be (untested):
ParameterMap copy = parameterMap.clone();
copy.setLocked(false);
> a time. Wonder if anyone would have any comments on the relative
> efficiency of the following two methods: [...]
> They are basically the same, but I wonder if calling getParameterMap() and
> then keySet() might result in double the processing of just calling
> getParameterNames().
I doubt if it makes any difference. I expect that getParameterNames()
ultimately reduces to a call to keySet() on the same underlying collection
object as is returned by getParameterMap().
-- chris
Scott Harper - 02 Mar 2007 19:03 GMT
>> Update... I revisited the copying idea, and it seems to work. The first
>> thing I tried was using Map.putAll() like:
[quoted text clipped - 6 lines]
> h.putAll(parameterMap);
>if you want to copy the parameter map into h.
Ah, I see... so would you expect this to be any more efficient than copying
all the key/values individually as below?
>Another way to get an unlocked copy would be (untested):
> ParameterMap copy = parameterMap.clone();
> copy.setLocked(false);
Well, the problem with this is that the Apache object is not in the classpath
(by default). So to use ParameterMap directly would require some
customization on the Tomcat setup (I presume). Otherwise I would just use
the original copy returned by getParameterMap.
And besides, I'd prefer not to have my implementation tied specifically to
Tomcat.
>> a time. Wonder if anyone would have any comments on the relative
>> efficiency of the following two methods: [...]
[quoted text clipped - 5 lines]
>ultimately reduces to a call to keySet() on the same underlying collection
>object as is returned by getParameterMap().
That's what I figured, but I wasn't sure if was missing something obvious.
scott
Chris Uppal - 02 Mar 2007 21:56 GMT
> > > Map parameterMap = request.getParameterMap();
> > > HashMap h = new HashMap();
[quoted text clipped - 6 lines]
> Ah, I see... so would you expect this to be any more efficient than
> copying all the key/values individually as below?
Take a look at the source -- it's almost exactly the same code ;-)
-- chris