users@jersey.java.net

Re: [Jersey] Comma Separated Lists in Jersey

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Tue, 5 Oct 2010 12:45:57 +0200

On Oct 5, 2010, at 2:31 AM, Leonardo wrote:

> http://jersey.576304.n2.nabble.com/Regular-Expression-matching-any-td5186256.html
>

The above is not really related to what Mike wants to achieve, the
above is more about regex matching rather than extracting values as a
comma separated list.

Mike, @*Param annotated types have a set of rules, see here:

   https://jersey.dev.java.net/nonav/documentation/latest/user-guide.html
#d0e494

So you can define say (off the top of my head, not compiled, or
dealing with errors!):

   public class CommaSeparatedValues extends ArrayList<String> {
     public CommaSeparatedValues(String list) {
       for (String s: list.split(",")) { add(s); }
     }
   }

You can also plug in your own types using StringReaderProvider:

   https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/spi/StringReaderProvider.html

Paul.

> 2010/10/4 Mike K <mkogan_at_semanticresearch.com>:
>>
>> I am working on a Jersey-enabled project, and I am noticing that
>> lists are
>> treated by people in the following manner:
>> resource?id=a&id=b&id=c
>> however, I think the following method translates the hierarchical and
>> homogeneity better:
>> resource/a,b,c
>> not to mention being more compact.
>> I am having a hard time finding if Jersey supports that.
>>
>> Any ideas?
>>
>> Thanks,
>>
>> Mike.
>> --
>> View this message in context: http://jersey.576304.n2.nabble.com/Comma-Separated-Lists-in-Jersey-tp5601352p5601352.html
>> Sent from the Jersey mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>