dev@jsr311.java.net

Re: URI Escaping and Unescaping

From: Dhanji R. Prasanna <dhanji_at_gmail.com>
Date: Tue, 26 Jun 2007 08:32:52 +1000

On 6/26/07, Marc Hadley <Marc.Hadley_at_sun.com> wrote:
>
> Good discussion, I think there are valid arguments both ways wrt
> automatic encoding and decoding. On balance I think that providing
> some form of automatic encoding and decoding is desirable and will be
> least surprising to folks already familiar with the Servlet API or
> CGI. However I can also see cases where developers would rather the
> API get out of the way in that area so here's what I propose we do:
>
> @UriParam, @QueryParam, @MatrixParam - add a boolean 'decode'
> property with a default value of true.



+1. You beat me to it. I was actually going to suggest autoDecode="true"

I would still encourage keeping the value method rather than renaming it:
@UriParam(value="paramname", autoDecode=false)

because it lets you use the shorthand:
@UriParam("paramname")

On more thought I think we should consider Paul's solution as it is more
elegant; because you can do:

@Decode @HttpMethod
public void get(@UriParam("param1") String p1, @UriParam("param2") String
p2, ....) { }

without being explicit on each parameter (or overriding on each as
required). You can even declare @Decode on an entire type as a shortcut.

Dhanji.