dev@glassfish.java.net

Re: name/value class?

From: Richard S. Hall <heavy_at_ungoverned.org>
Date: Fri, 30 Apr 2010 12:11:25 -0400

On 4/29/10 23:12, Bill Shannon wrote:
> 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!

Interesting. I looked around, but couldn't find an impl...but I probably
wasn't looking in Java 6.

>
> 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...

I wasn't saying you should use a Map, just that you could use an impl of
Map.Entry, since it is purely a NameValue, no? Apparently AbstractMap
provides a mutable and immutable impl of Map.Entry.

-> richard

>
> The real shame is that the Servlet spec hasn't solved this problem...
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>