users@jsr311.java.net

Re: JAX-RS: _at_Path limited=false templates: (?!/).+(?<!/)

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Wed, 02 Jul 2008 13:05:54 -0400

On Jul 2, 2008, at 12:53 PM, Stephan Koops wrote:
>>> Don't forget, that we need also a regular expression for @Path("/
>>> abc/de{FGH: .*}fg/image"} and List<PathSegment>.
>> I don't understand what you mean. The regular expression for
>> matching would be: /abc/de(.*)fg/image. So e.g.
>>
>> @PathParam("FGH") List<PathSegment> fgh would give values for foo as:
>>
>> /abc/defg/image => {"defg"}
>> /abc/de1fg/image => {"de1fg"}
>> /abc/de1/2fg/image => {"de1","2fg"}
> Yes, you are right. I thought it was more complicated to match than
> it is.
>
> What should happens, if we have two possibilites to match? e.g.
> @Path("/abc/de{FGH: .*}fg/hij"} on a sub resource locator with the
> request uri "/abc/de123fg/hij/abc/de456fg/hij"?
> is FGH = 123 and the remaining path is "abc/de456fg/hij" or FGH =
> "123fg/hij/abc/de456fg/hij" and the remaining path is empty? Or are
> they only allowed on (sub) resource methods? In the javadoc of Path
> I found nothing about it.
>
The spec currently says to substitute a template var with ([ˆ/]+?).
The ? is a reluctant qualifier so the capturing group terminates as
soon possible. In your example above there's no reluctant qualifier so
FGH would equal "123fg/jij/abc/de456". You could make it reluctant by
specifying {FGH:.*?} and then FGH would equal "123".

For just @Path("/abc/de{FGH}fg/hij"} we would continue to substitute
the default ([ˆ/]+?) which limits the capturing group to a single path
segment.

Marc.

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.