class UriUtils {

    public static URI extendUri(URI uri, String path) {
        String query = null;
        if (path != null) {
            final int indexOfFirstQueryChar = path.indexOf(URI_QUERY_CHAR_CONST);
            if (indexOfFirstQueryChar >= 0) {
                if (indexOfFirstQueryChar < path.length() - 1) {
                    query = path.substring(indexOfFirstQueryChar + 1);
                }
                path = path.substring(0, indexOfFirstQueryChar);
            }
        }
        return buildUri(uri.getScheme(), uri.getHost(), uri.getPort(),
                buildUriPath(uri.getPath(), path), query);
    }

    private  UriUtils();

}