users@jersey.java.net

Re: [Jersey] Example of matrix URIs?

From: Gili <cowwoc_at_bbs.darktech.org>
Date: Mon, 10 Nov 2008 13:40:02 -0800 (PST)

Paul Sandoz wrote:
>
> A better use would be:
>
> http://example.com/images;1;2;5/tags
>
> as then the matrix parameters are associated with a named path
> segment. Matrix parameters are ignored when path matching. The best
> way to think about them is as query parameters scoped to a path segment.
>

I don't understand how the above would work. Are you saying that "images"
would have 3 matrix parameters: 1, 2 and 5? Or would images be a matrix
parameter itself?


Paul Sandoz wrote:
>
> You can also use a URI like:
>
> http://example.com/images/1,2,5/tags
>
>

Does it matter whether I use commas or semicolons? I would prefer using
semicolons to hint that the element order is not important.


Paul Sandoz wrote:
>
> if you wish and don't require support for name value pairs and require
> that the path segment of the list of image names be matched.
>
> You should be able to do this:
>
> @GET_at_Path("{id: image}/tags")
> public ... get(@PathParam("id") PathSegment ps) { ... }
>
> and from the PathSegment you can get the multivalued map of matrix
> parameters.
>

I'm confused. What does @Path("{id: image}") signify? It looks like id is
the parameter name, but what does "image" refer to?


Paul Sandoz wrote:
>
> @MatrixParam will not be much use to you as you want to be rather general.
>

I'm not sure I understand. What's the difference between @MatrixParam and
@PathParam in this case?


Paul Sandoz wrote:
>
> If you are using the path segment matching approach you could do:
>
> @GET_at_Path("images/{id: <regex for digits and commas>}/tags")
> public ... get(@PathParam("id") ImageList images) { ... }
>
> and the class ImageList has a string constructor that parses the comma
> separated list of names (see the Sparklines sample [1]).
>

Okay, I just wanted to get back a List<Integer>. I guess I could code this
up myself.

Gili
-- 
View this message in context: http://n2.nabble.com/Example-of-matrix-URIs--tp1482069p1482378.html
Sent from the Jersey mailing list archive at Nabble.com.