dev@glassfish.java.net

Re: name/value class?

From: Bill Shannon <bill.shannon_at_oracle.com>
Date: Thu, 29 Apr 2010 20:12:16 -0700

Tim Quinn wrote on 04/29/2010 05:00 PM:
>
> On Apr 29, 2010, at 6:51 PM, Richard S. Hall wrote:
>
>> On 4/29/10 7:49 PM, Richard S. Hall wrote:
>>> On 4/29/10 7:44 PM, Tim Quinn wrote:
>>>> I don't have other nominees to fill this need from the GlassFish
>>>> source. (There are some name/value related classes in the
>>>> deployment/dol module but they are very focused on descriptor
>>>> processing and might not be too useful generally.)
>>>>
>>>> As I think about this, I usually encounter the need for name/value
>>>> pairs along with the need to collect them and iterate through
>>>> them...features that Map or some other collection provides. So I
>>>> sometimes use a HashMap (or LinkedHashMap if I need the insertion
>>>> order reflected in the iteration order) and then iterate through the
>>>> Map's entrySet members.
>>>
>>> Right, I was going to say that Map.Entry is a candidate, no?
>>
>> Well, I guess not, since it is only an interface... :-(
> Hence the AbstractMap.SimpleEntry<K,V> class!

Ya, uh, that's pretty far afield from what I want.

I started by considering a Map, but each key needs to support
multiple values so I considered MultiMap, which I've used elsewhere,
but then I thought that I should probably preserve the order of the
headers in case it will someday matter to someone. I thought about
LinkedHashMap, but I needed LinkedHashMultiMap. Can you spell "overkill"?

So, I'm back to List and I just need an entry to put in the list.
I guess I can be the first to use NameValue...

The real shame is that the Servlet spec hasn't solved this problem...