<p>relativize.</p>

@param base a {@link java.lang.String} object.
@param uri a {@link java.lang.String} object.
@return a {@link java.lang.String} object.
164804
public static String relativize(String base, String uri)
	{
		URI child = URI.create( raw( uri ) );
		URI parent = URI.create( raw( base ) );
		return parent.relativize( child ).getPath();
	}
343266
private String rewriteUri(String internalUri) {

        // if an object wrapper is used, rewrite the uri
        if (m_cms != null) {
            Object obj = m_cms.getRequestContext().getAttribute(CmsObjectWrapper.ATTRIBUTE_NAME);
            if (obj != null) {
                CmsObjectWrapper wrapper = (CmsObjectWrapper)obj;
                return wrapper.restoreLink(internalUri);
            }
        }

        return internalUri;
    }
393282
public static String getUri(String uri) throws IOException {
        CloseableHttpClient c = newHttpClient(new URL(uri));
        HttpGet get = new HttpGet(uri);
        LOG.debug("GET {}", uri);
        CloseableHttpResponse res = c.execute(get, HttpClientContext.create());
        return checkResponse(res);
    }
215642
public String relative(String url)
	{
		try
		{
			final URI uri = absolute(url).build();

			return new URI(null, null, uri.getPath(), uri.getQuery(), uri.getFragment()).toString();
		}
		catch (URISyntaxException e)
		{
			throw new IllegalArgumentException(e);
		}
	}
644536
public void normalizeURI(I invocation, String rawURI)
    throws IOException
  {
    invocation.setRawURI(rawURI);
    
    String uri = normalizeUri(rawURI);

    invocation.setURI(uri);
  }
624513
public static URI toURI(String uri) throws URISyntaxException {
		final URI u = new URI(uri);
		// Inspired by ZeroMQ
		String adr = u.getAuthority();
		if (adr == null) {
			adr = u.getPath();
		}
		if (adr != null && adr.endsWith(":*")) { //$NON-NLS-1$
			return new URI(u.getScheme(), u.getUserInfo(), adr.substring(0, adr.length() - 2), -1, null, u.getQuery(),
					u.getFragment());
		}
		return u;
	}
732235
public static URI toURI(String location) throws UtilException {
		try {
			return new URI(location.replace(" ", "%20"));
		} catch (URISyntaxException e) {
			throw new UtilException(e);
		}
	}
602617
public static <T> Rule<T> fromUri(final String uri, final String methods, final T target) {
    return new Rule<>(uri, singletonList(methods), target);
  }
1008971
public URI rewriteURI(RequestContext rc) throws URISyntaxException {
        Request request = rc.request();
        String path = request.path();
        if (!path.startsWith(prefix)) {
            return null;
        }

        return computeDestinationURI(request, path, proxyTo, prefix);
    }
246266
public static Condition uri(final String uri) {
        return new Condition(input -> input.getUri().equals(uri));
    }
981056
private static String resolveURI(final URL baseURI, final Parent parent, String url) {
        url = url.equals(".") || url.equals("./") ? "" : url;
        if (isRelativeURI(url) && parent != null && parent instanceof Element) {
            final Attribute baseAtt = ((Element) parent).getAttribute("base", Namespace.XML_NAMESPACE);
            String xmlBase = baseAtt == null ? "" : baseAtt.getValue();
            if (!isRelativeURI(xmlBase) && !xmlBase.endsWith("/")) {
                xmlBase = xmlBase.substring(0, xmlBase.lastIndexOf("/") + 1);
            }
            return resolveURI(baseURI, parent.getParent(), xmlBase + url);
        } else if (isRelativeURI(url) && parent == null) {
            return baseURI + url;
        } else if (baseURI != null && url.startsWith("/")) {
            String hostURI = baseURI.getProtocol() + "://" + baseURI.getHost();
            if (baseURI.getPort() != baseURI.getDefaultPort()) {
                hostURI = hostURI + ":" + baseURI.getPort();
            }
            return hostURI + url;
        }
        return url;
    }
983497
static private String resolve(String base, String rel) {
    // Short-circuit check for unspecified base or relative URI.
    if (base == null || base.isEmpty()) return rel;
    if (rel == null || rel.isEmpty()) return base;
    
    // Attempt to parse both strings as URIs.
    URI b = null;
    try {
      b = new URI(base);
    } catch (URISyntaxException IGNORE) {
      // ignore, we'll handle this later.
    }
    URI r = null;
    try {
      r = new URI(rel);
    } catch (URISyntaxException IGNORE) {
      // ignore, we'll handle this later.
    }
    
    // Both URIs parsed OK, proceed as usual.
    if (b != null && r != null) return b.resolve(r).toString();
    
    // Syntax exception in the base or relative URI, need to fudge here...
    // Is the URI being resolved absolute (or does it look like it)?
    if ((r != null && r.isAbsolute()) || rel.startsWith("http:")) return rel;
    
    // One or both of the strings didn't parse as a valid URI so URI.resolve won't help us here.
    // Just smash them together and hope for the best.
    return base + rel;
  }
135453
protected String toBaseURI(String uri) {
    LoaEnum loa = LoaEnum.parse(uri);
    if (loa != null && loa.isSignatureMessageUri()) {
      return LoaEnum.minusSigMessage(loa).getUri();
    }
    return uri;
  }
266359
public XPointerEngine setBaseURI(final String baseURI)
    {
        if (baseURI == null)
        {
            this.baseURIValue = XdmEmptySequence.getInstance();
        }
        else
        {
            this.baseURIValue = new XdmAtomicValue(baseURI);
        }
        return this;
    }
284010
public static String resolveURI(final String baseURI, final Parent parent, String url) {

        if (!resolveURIs) {
            return url;
        }

        if (isRelativeURI(url)) {

            if (".".equals(url) || "./".equals(url)) {
                url = "";
            }

            if (url.startsWith("/") && baseURI != null) {
                String base = null;
                final int slashslash = baseURI.indexOf("//");
                final int nextslash = baseURI.indexOf("/", slashslash + 2);
                if (nextslash != -1) {
                    base = baseURI.substring(0, nextslash);
                }
                return formURI(base, url);
            }

            // Relative URI with parent
            if (parent != null && parent instanceof Element) {

                // Do we have an xml:base?
                String xmlbase = ((Element) parent).getAttributeValue("base", Namespace.XML_NAMESPACE);
                if (xmlbase != null && xmlbase.trim().length() > 0) {
                    if (isAbsoluteURI(xmlbase)) {
                        // Absolute xml:base, so form URI right now
                        if (url.startsWith("/")) {
                            // Host relative URI
                            final int slashslash = xmlbase.indexOf("//");
                            final int nextslash = xmlbase.indexOf("/", slashslash + 2);
                            if (nextslash != -1) {
                                xmlbase = xmlbase.substring(0, nextslash);
                            }
                            return formURI(xmlbase, url);
                        }
                        if (!xmlbase.endsWith("/")) {
                            // Base URI is filename, strip it off
                            xmlbase = xmlbase.substring(0, xmlbase.lastIndexOf("/"));
                        }
                        return formURI(xmlbase, url);
                    } else {
                        // Relative xml:base, so walk up tree
                        return resolveURI(baseURI, parent.getParent(), stripTrailingSlash(xmlbase) + "/" + stripStartingSlash(url));
                    }
                }
                // No xml:base so walk up tree
                return resolveURI(baseURI, parent.getParent(), url);

                // Relative URI with no parent (i.e. top of tree), so form URI
                // right now
            } else if (parent == null || parent instanceof Document) {
                return formURI(baseURI, url);
            }
        }

        return url;

    }
1020838
public static UriBuilder fromUri(Uri uri) throws IllegalArgumentException {
        if (uri == null)
            throw new IllegalArgumentException("Uri cannot be null");

        UriBuilder b = newInstance();
        b.uri(uri);
        return b;
    }
104631
public static URI resolveBase(final URI baseURI, final Stack<URI> stack) throws XIncludeFatalException
    {
        final URI computedUri = XIncProcUtils.computeBase(stack);
        final URI resolvedUri = baseURI.resolve(computedUri);
        if (0 == resolvedUri.compareTo(baseURI))
        {
            throw new XIncludeFatalException("Inclusion loop error");
        }
        return resolvedUri;
    }