class URIUtils {

    public static URI rewriteURI(
            final URI uri,
            final HttpHost target,
            boolean dropFragment) throws URISyntaxException {
        if (uri == null) {
            throw new IllegalArgumentException("URI may nor be null");
        }
        if (target != null) {
            return URIUtils.createURI(
                    target.getSchemeName(),
                    target.getHostName(),
                    target.getPort(),
                    normalizePath(uri.getRawPath()),
                    uri.getRawQuery(),
                    dropFragment ? null : uri.getRawFragment());
        } else {
            return URIUtils.createURI(
                    null,
                    null,
                    -1,
                    normalizePath(uri.getRawPath()),
                    uri.getRawQuery(),
                    dropFragment ? null : uri.getRawFragment());
        }
    }

    private  URIUtils();

}