dev@glassfish.java.net

Re: name/value class?

From: Tim Quinn <tim.quinn_at_oracle.com>
Date: Fri, 30 Apr 2010 09:44:58 -0500

On Apr 29, 2010, at 10:12 PM, 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!
>
> Ya, uh, that's pretty far afield from what I want.
Agreed. (I was responding more to Richard's comment about Map.Entry
than to your original quest for NameValue.)
>
> 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...
And that there's no NameValue class in java.util (or some other java
package).

- Tim
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>