dev@glassfish.java.net

Re: name/value class?

From: Justin Wyer <justin_at_lifeasageek.com>
Date: Fri, 30 Apr 2010 07:45:30 +0200

Bill why not use javax.ws.rs.core.MultivaluedMap? Are the rest
services for gfv3 provided by jersey, if so there would be an
implementation in there and there is already a dependency inplace.
Otherwise if you don't want to introduce a dependency, you can just
pillage an implementation of this from one of the jaxrs projects
(hooray for opensource) I think this is pretty much what you are
looking for, and it used for storing HttpHeaders in anycase.

On Fri, Apr 30, 2010 at 5:12 AM, Bill Shannon <bill.shannon_at_oracle.com> 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.
>
> 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...
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>
>