users@jsr311.java.net

Queries, UriBuilder.build(), UriBuilder.buildFromEncoded()

From: Sergey Beryozkin <sberyozkin_at_gmail.com>
Date: Thu, 23 Sep 2010 21:37:53 +0100

Hello -

Can someone please give me an authoritative answer about the differences
between UriBuilder.build() and UriBuilder.buildFromEncoded() and they way
they have to deal with quieries containing percent-encoded data.

1. UriBuilder.fromUri("http://localhost:8080").queryParam("name",
"%20").build();
2. UriBuilder.fromUri("http://localhost:8080").queryParam("name",
"%20").buildFromEncoded();
3. UriBuilder.fromUri("http://localhost:8080
").replaceQuery("name=%20").build();
4. UriBuilder.fromUri("http://localhost:8080
").replaceQuery("name=%20").buildFromEncoded();

I'm seriously confused. Specifically, it seems totally wrong that the way
'%' is dealt with depends on how a query is built (i.e, from individual
parameters or from a ready string).

I'd appreciate if you can give the answers to 1-4 above.
Besides, what is the way in UriBuilder to have a literal '%' passed on ?
Example, should it be :

UriBuilder.fromUri("http://localhost:8080").queryParam("name",
"%2520").buildFromEncoded();

or

UriBuilder.fromUri("http://localhost:8080
").replaceQuery("name=%2520").build();

How about

UriBuilder.fromUri("http://localhost:8080
").replaceQuery("name=%2520").buildFromEncoded();

versus

UriBuilder.fromUri("http://localhost:8080
").replaceQuery("name=%2520").build();

Thanks !

Sergey