Bill de hOra wrote:
> Marc Hadley wrote:
>
>> My working assumption, which isn't reflected in the Javadoc, is that
>> the developer would work with unescaped values for @UriParam,
>> @QueryParam and @MatrixParam so the value of name would be "x y".
>
> Mine too.
>
Mine too, and they would be unescaped using UTF-8 [1].
>>
>> A related question is whether the @UriTemplate value should be in
>> escaped or unescaped form. In this case I'd say that it should be in
>> escaped form, i.e. a developer would have to write
>> @UriTemplate("hello%20world") rather than @UriTemplate("hello world").
>
> That would make the API asymmetric/inconsistent...?
>
FWIW I notice that Firefox lets one type in a URI path "/hello world"
and it translates it to "/hello%20world".
Note that the @UriTemplate as currently used only deals with paths
(relative to the base URI).
There is another potential inconsistency in the following: what should
the UriInfo.getURIPath() [2] return, escaped or unescaped characters?
The reason being that:
info.getBaseURI().resolve(info.getURIPath()) [3]
would result in an error if the path is not escaped, but it is a very
convenient thing to use (and it is easy to forget, like me, to do
URLEncoder.encode(info.getURIPath(), "UTF-8"). In servlet the
HttpServletRequest.getPathInfo() is decoded (as per the CGI PATH_INFO
variable), as is URI.getPath().
Dealing with URIs and paths with java.net.URI is not easy... IMHO we
need some good classes/methods to create URIs from templates, decoded
paths (relative to the base URI) for embedding in content. I like RoR
way of managing URIs. I wonder what we could provide something that
tools can build upon to provide typed URIs?
Paul.
[1]
http://java.sun.com/j2se/1.5.0/docs/api/index.html
[2]
https://jsr311.dev.java.net/releases/0.1/javax/ws/rs/core/UriInfo.html#getURIPath()
[3]
http://java.sun.com/j2se/1.5.0/docs/api/java/net/URI.html#resolve(java.lang.String)
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109