users@jsr311.java.net

Re: Difference between UriBuilder.buildFromEncoded and UriBuilder.build

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Thu, 12 Mar 2009 10:41:14 -0400

On Mar 12, 2009, at 9:17 AM, Sergey Beryozkin wrote:

> I've used wrong URI string values containing spaces in examples,
> please assume such values has been added using
> UriBuilder.path(String) or UriBuilder.queryParam() methods. There's
> also a typo so here're revised examples
>
>
> assertEquals("http://bar/foo%20%252B+%2520%252?q=+%252B%2B%2520"
> UriBuilder.fromUri("http://bar/").path("foo %2B+
> %20%2").queryParam("q", " %2B+%20").build()).toString());
>
> assertEquals("http://bar/foo%20%2B+%20%252?q=+%2B%2B%20"
> UriBuilder.fromUri("http://bar/).path("foo %2B+
> %20%2").queryParam("q", " %2B+%20").buildfromEncoded().toString());
>
> I'd also to check that encoded %2B ('+') are retained in the encoded
> form after buildfromEncoded(). '+' are untouched in the path
> segments while converted to %2B in queries, finally ' ' is replaced
> with '+' in queries
>
Those both look right to me.

Marc.

>>
>> Few more questions about UriBuilder.buildFromEncoded().
>>
>> Basically, affer reading the JavaDocs again, my understanding is
>> that the only difference between UriBuilder.buildFromEncoded() and
>> UriBuilder.build() is that in the latter case every character is
>> encoded (except for the reserved path segment characters), while
>> with the former everything is also encoded with the exception of
>> percent-encoded values left untouched.
>>
>> Is it a correct interpretation ?
>>
>> Here're 2 examples to verify if I'm getting it right :
>>
>> assertEquals("http://bar/foo%20%252B+%2520%252?q=+%252B%2B%2520"
>> UriBuilder.fromUri("http://bar/foo %2B+%20%2?q=
>> %2B+%20").build(),toString());
>>
>> assertEquals("http://bar/foo%20%2B+%20%252?q= +%2B%2B%20"
>> UriBuilder.fromUri("http://bar/foo %2B+%20%2?q=
>> %2B+%20").buildfromEncoded(),toString());
>>
>> Is it correct?
>> thanks, Sergey
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: users-help_at_jsr311.dev.java.net
>