jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: More confusion about UriBuilder.build and UriBuilder.resolveTemplate

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Tue, 23 Oct 2012 12:44:22 +0100

On 22/10/12 13:44, Marek Potociar wrote:
>
> On Oct 22, 2012, at 1:54 PM, Sergey Beryozkin<sberyozkin_at_talend.com> wrote:
>
>> I'm confused about how the combination of UriBuilder.resolveTemplate(0 and UriBuilder.build() is supposed to work correctly together.
>>
>> Consider:
>>
>> UriBuilder ub = UriBuilder.fromPath("http://localhost/{a}/{b}?bar={bar}");
>>
>> ub.resolveTemplate("a", "1");
>> ub.build("2", "3");
>>
>> Do we end up with
>>
>> "http://localhost/1/2?bar=3}"
>>
>> in the end ?
>
> Yes.
>
> Which part of resolveTemplate() javadoc you find confusing? Can you suggest the wording that would make the javadoc more clear?

Yes. Something along these lines, in bold: "Note that resolveTemplates
provides a positional resolution of template variables thus the use of
this method in combination with either of the build methods for the
purpose of the template variable substitution is not recommended" and
possibly give an example:

UriBuilder ub = UriBuilder.fromPath("http://localhost/{a}/{b}?bar={bar}");
ub.resolveTemplate("b", "1");
ub.build("2", "3");

that supposed to substitute the 1st and the last template var - which I
honestly don't think anyone will attempt to do, in other words, the
recommendation should be: stick to either resolveTemplate or build but
avoid using the two together.

Sergey




>
> Thanks,
> Marek
>
>>
>> Thanks, Sergey
>>
>>
>>
>>
>


-- 
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com