users@jax-rs-spec.java.net

[jax-rs-spec users] [jsr339-experts] Re: Re: Link.Builder.buildRelativized() examples?

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Fri, 22 Mar 2013 19:18:38 +0100

On Mar 22, 2013, at 12:50 AM, Bill Burke <bburke_at_redhat.com> wrote:

> From looking at Jersey codebase. This:
>
> Link link = Link.fromUri("a/d/e")
> .rel("update").type("text/plain")
> .buildRelativized(new URI("a"));
>
> would internally equate to:
>
> URI base = new URI("a");
> URI supplied = new URI("a/d/e");
> URI linkUri = base.relativized(supplied);
>
> Jersey codebase is correct?

Yes, that's correct, even though as the author of the code I may be biased. :)

Te general steps to follow are:

set link uri
if link uri is relative, set base uri
relativize:
  if link uri is relative, resolve it using the base uri
  relativize resolved uri against supplied uri

HTH,
Marek
>
> On 3/21/2013 7:18 PM, Bill Burke wrote:
>> I'm confused on how Link.builder.buildRelativized() along with the
>> corresponding baseUri() methods are supposed to work. Can you provide a
>> few full examples please and what the output URI would look like?
>>
>> For example, I don't know if
>>
>> * its underlyingUri.relativize(param) or param.relativize(underlyingUri)
>> * the output is equivalent to UriInfo.relativize()? or URI.relativize()?
>>
>> You following me? Please provide some examples.
>>
>>
>>
>>
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com