/** * Resolve the base and relative path. * * @param basePath a character array of the basePath * @param relPath a character array of the relPath * @return the resolved path * @throws URIException no more higher path level to be resolved */ protected char[] resolvePath(char[] basePath, char[] relPath) throws URIException { // REMINDME: paths are never null String base = (basePath == null) ? "" : new String(basePath); // _path could be empty if (relPath == null || relPath.length == 0) { return normalize(basePath); } else if (relPath[0] == '/') { return normalize(relPath); } else { int at = base.lastIndexOf('/'); if (at != -1) { basePath = base.substring(0, at + 1).toCharArray(); } StringBuffer buff = new StringBuffer(base.length() + relPath.length); buff.append((at != -1) ? base.substring(0, at + 1) : "/"); buff.append(relPath); return normalize(buff.toString().toCharArray()); } }
/** * Normalizes the path part of this URI. Normalization is only meant to be performed on * URIs with an absolute path. Calling this method on a relative path URI will have no * effect. * * @throws URIException no more higher path level to be normalized * * @see #isAbsPath() */ public void normalize() throws URIException { if (isAbsPath()) { _path = normalize(_path); setURI(); } }
/** * Resolve the base and relative path. * * @param basePath a character array of the basePath * @param relPath a character array of the relPath * @return the resolved path * @throws URIException no more higher path level to be resolved */ protected char[] resolvePath(char[] basePath, char[] relPath) throws URIException { // REMINDME: paths are never null String base = (basePath == null) ? "" : new String(basePath); // _path could be empty if (relPath == null || relPath.length == 0) { return normalize(basePath); } else if (relPath[0] == '/') { return normalize(relPath); } else { int at = base.lastIndexOf('/'); if (at != -1) { basePath = base.substring(0, at + 1).toCharArray(); } StringBuffer buff = new StringBuffer(base.length() + relPath.length); buff.append((at != -1) ? base.substring(0, at + 1) : "/"); buff.append(relPath); return normalize(buff.toString().toCharArray()); } }
/** * Resolve the base and relative path. * * @param basePath a character array of the basePath * @param relPath a character array of the relPath * @return the resolved path * @throws URIException no more higher path level to be resolved */ protected char[] resolvePath(char[] basePath, char[] relPath) throws URIException { // REMINDME: paths are never null String base = (basePath == null) ? "" : new String(basePath); // _path could be empty if (relPath == null || relPath.length == 0) { return normalize(basePath); } else if (relPath[0] == '/') { return normalize(relPath); } else { int at = base.lastIndexOf('/'); if (at != -1) { basePath = base.substring(0, at + 1).toCharArray(); } StringBuffer buff = new StringBuffer(base.length() + relPath.length); buff.append((at != -1) ? base.substring(0, at + 1) : "/"); buff.append(relPath); return normalize(buff.toString().toCharArray()); } }
/** * Resolve the base and relative path. * * @param basePath a character array of the basePath * @param relPath a character array of the relPath * @return the resolved path * @throws URIException no more higher path level to be resolved */ protected char[] resolvePath(char[] basePath, char[] relPath) throws URIException { // REMINDME: paths are never null String base = (basePath == null) ? "" : new String(basePath); // _path could be empty if (relPath == null || relPath.length == 0) { return normalize(basePath); } else if (relPath[0] == '/') { return normalize(relPath); } else { int at = base.lastIndexOf('/'); if (at != -1) { basePath = base.substring(0, at + 1).toCharArray(); } StringBuffer buff = new StringBuffer(base.length() + relPath.length); buff.append((at != -1) ? base.substring(0, at + 1) : "/"); buff.append(relPath); return normalize(buff.toString().toCharArray()); } }
/** * Resolve the base and relative path. * * @param basePath a character array of the basePath * @param relPath a character array of the relPath * @return the resolved path * @throws URIException no more higher path level to be resolved */ protected char[] resolvePath(char[] basePath, char[] relPath) throws URIException { // REMINDME: paths are never null String base = (basePath == null) ? "" : new String(basePath); // _path could be empty if (relPath == null || relPath.length == 0) { return normalize(basePath); } else if (relPath[0] == '/') { return normalize(relPath); } else { int at = base.lastIndexOf('/'); if (at != -1) { basePath = base.substring(0, at + 1).toCharArray(); } StringBuffer buff = new StringBuffer(base.length() + relPath.length); buff.append((at != -1) ? base.substring(0, at + 1) : "/"); buff.append(relPath); return normalize(buff.toString().toCharArray()); } }
/** * Resolve the base and relative path. * * @param basePath a character array of the basePath * @param relPath a character array of the relPath * @return the resolved path * @throws URIException no more higher path level to be resolved */ protected char[] resolvePath(char[] basePath, char[] relPath) throws URIException { // REMINDME: paths are never null String base = (basePath == null) ? "" : new String(basePath); // _path could be empty if (relPath == null || relPath.length == 0) { return normalize(basePath); } else if (relPath[0] == '/') { return normalize(relPath); } else { int at = base.lastIndexOf('/'); if (at != -1) { basePath = base.substring(0, at + 1).toCharArray(); } StringBuffer buff = new StringBuffer(base.length() + relPath.length); buff.append((at != -1) ? base.substring(0, at + 1) : "/"); buff.append(relPath); return normalize(buff.toString().toCharArray()); } }
private String normalize(String uri) throws URISyntaxException { try { URI normalized = new URI(uri, DefaultHTTPClient.isUrlEncoded(uri)); normalized.normalize(); return normalized.toString(); } catch (URIException e) { LOG.warn("Invalid uri: {}", uri); LOG.error("Can not convert URL", e); throw new URISyntaxException(uri, e.getMessage()); } }
/** * Normalizes the path part of this URI. Normalization is only meant to be performed on * URIs with an absolute path. Calling this method on a relative path URI will have no * effect. * * @throws URIException no more higher path level to be normalized * * @see #isAbsPath() */ public void normalize() throws URIException { if (isAbsPath()) { _path = normalize(_path); setURI(); } }
/** * Normalizes the path part of this URI. Normalization is only meant to be performed on * URIs with an absolute path. Calling this method on a relative path URI will have no * effect. * * @throws URIException no more higher path level to be normalized * * @see #isAbsPath() */ public void normalize() throws URIException { if (isAbsPath()) { _path = normalize(_path); setURI(); } }
/** * Normalizes the path part of this URI. Normalization is only meant to be performed on * URIs with an absolute path. Calling this method on a relative path URI will have no * effect. * * @throws URIException no more higher path level to be normalized * * @see #isAbsPath() */ public void normalize() throws URIException { if (isAbsPath()) { _path = normalize(_path); setURI(); } }
/** * Normalizes the path part of this URI. Normalization is only meant to be performed on * URIs with an absolute path. Calling this method on a relative path URI will have no * effect. * * @throws URIException no more higher path level to be normalized * * @see #isAbsPath() */ public void normalize() throws URIException { if (isAbsPath()) { _path = normalize(_path); setURI(); } }
/** * Normalizes the path part of this URI. Normalization is only meant to be performed on * URIs with an absolute path. Calling this method on a relative path URI will have no * effect. * * @throws URIException no more higher path level to be normalized * * @see #isAbsPath() */ public void normalize() throws URIException { if (isAbsPath()) { _path = normalize(_path); setURI(); } }