@Test public void testRelativize$same() { URI base = URI.create(BASE); assertThat(URIUtils.relativize(base, base),equalTo(URI.create(""))); }
public static URI relativize(URI base, URI target) { Objects.requireNonNull(base,BASE_URI_CANNOT_BE_NULL); Objects.requireNonNull(target,TARGET_URI_CANNOT_BE_NULL); URI nTarget = target.normalize(); if(areRelativizable(base,target)) { URI nBase=base.normalize(); if(nBase.equals(nTarget)) { nTarget=URI.create(EMPTY); } else { URI walkthrough = absoluteRelativization(nBase,nTarget); if(!(walkthrough.getPath().startsWith(PARENT) && nTarget.getPath().isEmpty())) { nTarget=walkthrough; } } } return nTarget; }
URIUtils { public static URI relativize(URI base, URI target) { Objects.requireNonNull(base,BASE_URI_CANNOT_BE_NULL); Objects.requireNonNull(target,TARGET_URI_CANNOT_BE_NULL); URI nTarget = target.normalize(); if(areRelativizable(base,target)) { URI nBase=base.normalize(); if(nBase.equals(nTarget)) { nTarget=URI.create(EMPTY); } else { URI walkthrough = absoluteRelativization(nBase,nTarget); if(!(walkthrough.getPath().startsWith(PARENT) && nTarget.getPath().isEmpty())) { nTarget=walkthrough; } } } return nTarget; } }
URIUtils { public static URI relativize(URI base, URI target) { Objects.requireNonNull(base,BASE_URI_CANNOT_BE_NULL); Objects.requireNonNull(target,TARGET_URI_CANNOT_BE_NULL); URI nTarget = target.normalize(); if(areRelativizable(base,target)) { URI nBase=base.normalize(); if(nBase.equals(nTarget)) { nTarget=URI.create(EMPTY); } else { URI walkthrough = absoluteRelativization(nBase,nTarget); if(!(walkthrough.getPath().startsWith(PARENT) && nTarget.getPath().isEmpty())) { nTarget=walkthrough; } } } return nTarget; } private  URIUtils(); }
URIUtils { public static URI relativize(URI base, URI target) { Objects.requireNonNull(base,BASE_URI_CANNOT_BE_NULL); Objects.requireNonNull(target,TARGET_URI_CANNOT_BE_NULL); URI nTarget = target.normalize(); if(areRelativizable(base,target)) { URI nBase=base.normalize(); if(nBase.equals(nTarget)) { nTarget=URI.create(EMPTY); } else { URI walkthrough = absoluteRelativization(nBase,nTarget); if(!(walkthrough.getPath().startsWith(PARENT) && nTarget.getPath().isEmpty())) { nTarget=walkthrough; } } } return nTarget; } private  URIUtils(); static URL toURL(URI uri); static URI relativize(URI base, URI target); static URI resolve(URI base, URI target); }
URIUtils { public static URI relativize(URI base, URI target) { Objects.requireNonNull(base,BASE_URI_CANNOT_BE_NULL); Objects.requireNonNull(target,TARGET_URI_CANNOT_BE_NULL); URI nTarget = target.normalize(); if(areRelativizable(base,target)) { URI nBase=base.normalize(); if(nBase.equals(nTarget)) { nTarget=URI.create(EMPTY); } else { URI walkthrough = absoluteRelativization(nBase,nTarget); if(!(walkthrough.getPath().startsWith(PARENT) && nTarget.getPath().isEmpty())) { nTarget=walkthrough; } } } return nTarget; } private  URIUtils(); static URL toURL(URI uri); static URI relativize(URI base, URI target); static URI resolve(URI base, URI target);  }