dev@jsr311.java.net

Re: JSR311: Proposal for regexs in path template vars

From: Bill Burke <bburke_at_redhat.com>
Date: Tue, 22 Jul 2008 17:06:19 -0400

Looks good.

Marc Hadley wrote:
> After some experimentation I've convinced myself that allowing
> developers to specify regexs for their template parameters is workable.
> Here's what I propose we do:
>
> (a) Allow the developer to specify the content of the capturing group
> for a template parameter. E.g. {foo: .+} would result in a capturing
> group (.+) in the regex generated for the template. Whitespace around
> the parameter name and regex will be stripped.
> (b) If no regex is specified you get ([^/]+).
> (c) Implementations will not be required to encode literals in the regex
> (regardles of whether @Path.encode==true), developers have to do that
> themselves.
> (d) Remove the @Path.limited property since developers can use a regex
> to adjust the bounds of a capturing group.
> (e) The regex will be ignored by UriBuilder (no validation).
> (f) For the purposes of the matching algorithm, the regex resulting from
> a template will always have (/.*)? appended to the end (see existing
> 3.7.3 step 6).
>
> I attach some examples as a HTML table.
>
> Marc.
>
> ---
> Marc Hadley <marc.hadley at sun.com>
> CTO Office, Sun Microsystems.
>
>
> ------------------------------------------------------------------------
>
> URI Template Pattern Capturing Groups
> 1 {n} ([^/]+)(/.*)? [n: 1] [final: null]
> 1/ {n} ([^/]+)(/.*)? [n: 1] [final: /]
> 1/2 {n} ([^/]+)(/.*)? [n: 1] [final: /2]
> 1 {n: .+} (.+)(/.*)? [n: 1] [final: null]
> 1.htm {n: .+}.htm (.+).htm(/.*)? [n: 1] [final: null]
> 1/ {n: .+} (.+)(/.*)? [n: 1/] [final: null]
> 1/2 {n: .+} (.+)(/.*)? [n: 1/2] [final: null]
> 1/2 {n}/{m} ([^/]+)/([^/]+)(/.*)? [n: 1] [m: 2] [final: null]
> 1/2.htm {n}/{m}.htm ([^/]+)/([^/]+).htm(/.*)? [n: 1] [m: 2] [final: null]
> 1/2 {n: .+}/{m} (.+)/([^/]+)(/.*)? [n: 1] [m: 2] [final: null]
> 1/2 {n: .+}/{m: .+} (.+)/(.+)(/.*)? [n: 1] [m: 2] [final: null]
> 1/2/3 {n: .+}/{m} (.+)/([^/]+)(/.*)? [n: 1/2] [m: 3] [final: null]
> 1/2/3 {n:.+}/{m: .+} (.+)/(.+)(/.*)? [n: 1/2] [m: 3] [final: null]
> 1/2 {n}/{m: .+} ([^/]+)/(.+)(/.*)? [n: 1] [m: 2] [final: null]
> 1/2/3 {n}/{m: .+} ([^/]+)/(.+)(/.*)? [n: 1] [m: 2/3] [final: null]
> 1/2/3/4 {n}/{m: .+}/{p} ([^/]+)/(.+)/([^/]+)(/.*)? [n: 1] [m: 2/3] [p:
> 4] [final: null]
> 1/2/3/4/ {n}/{m: .+}/{p} ([^/]+)/(.+)/([^/]+)(/.*)? [n: 1] [m: 2/3] [p:
> 4] [final: /]
>
>
>
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: dev-help_at_jsr311.dev.java.net

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com