@Test public void testRelativize$baseRootDir$toDeepDir() { String base = "http: String target = "http: String resolution = "smart-aggregator/common/segment2/segment3/target/"; assertThat(URI.create(base).resolve(URI.create(resolution)),equalTo(URI.create(target))); verifyConfigurableRelativizationScenario(base, target, resolution, false, false); verifyConfigurableRelativizationScenario(base, target, resolution, false, true); verifyConfigurableRelativizationScenario(base, target, resolution, true, false); verifyConfigurableRelativizationScenario(base, target, resolution, true, true); }
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);  }