/** * Initializes a path object given the scheme, authority and path string. * * @param scheme * the scheme string. * @param authority * the authority string. * @param path * the path string. */ private void initialize(String scheme, String authority, String path) { try { this.uri = new URI(scheme, authority, normalizePath(path), null, null).normalize(); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } }
/** * Resolve a child path against a parent path. * * @param parent * the parent path * @param child * the child path */ public Path(Path parent, Path child) { // Add a slash to parent's path so resolution is compatible with URI's URI parentUri = parent.uri; final String parentPath = parentUri.getPath(); if (!(parentPath.equals("/") || parentPath.equals(""))) { try { parentUri = new URI(parentUri.getScheme(), parentUri.getAuthority(), parentUri.getPath() + "/", null, null); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } } if (child.uri.getPath().startsWith(Path.SEPARATOR)) { child = new Path(child.uri.getScheme(), child.uri.getAuthority(), child.uri.getPath().substring(1)); } final URI resolved = parentUri.resolve(child.uri); initialize(resolved.getScheme(), resolved.getAuthority(), normalizePath(resolved.getPath())); }
/** * Initializes a path object given the scheme, authority and path string. * * @param scheme * the scheme string. * @param authority * the authority string. * @param path * the path string. */ private void initialize(String scheme, String authority, String path) { try { this.uri = new URI(scheme, authority, normalizePath(path), null, null).normalize(); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } }
/** * Initializes a path object given the scheme, authority and path string. * * @param scheme * the scheme string. * @param authority * the authority string. * @param path * the path string. */ private void initialize(String scheme, String authority, String path) { try { this.uri = new URI(scheme, authority, normalizePath(path), null, null).normalize(); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } }
/** * Resolve a child path against a parent path. * * @param parent * the parent path * @param child * the child path */ public Path(Path parent, Path child) { // Add a slash to parent's path so resolution is compatible with URI's URI parentUri = parent.uri; final String parentPath = parentUri.getPath(); if (!(parentPath.equals("/") || parentPath.equals(""))) { try { parentUri = new URI(parentUri.getScheme(), parentUri.getAuthority(), parentUri.getPath() + "/", null, null); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } } if (child.uri.getPath().startsWith(Path.SEPARATOR)) { child = new Path(child.uri.getScheme(), child.uri.getAuthority(), child.uri.getPath().substring(1)); } final URI resolved = parentUri.resolve(child.uri); initialize(resolved.getScheme(), resolved.getAuthority(), normalizePath(resolved.getPath())); }
/** * Resolve a child path against a parent path. * * @param parent * the parent path * @param child * the child path */ public Path(Path parent, Path child) { // Add a slash to parent's path so resolution is compatible with URI's URI parentUri = parent.uri; final String parentPath = parentUri.getPath(); if (!(parentPath.equals("/") || parentPath.equals(""))) { try { parentUri = new URI(parentUri.getScheme(), parentUri.getAuthority(), parentUri.getPath() + "/", null, null); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } } if (child.uri.getPath().startsWith(Path.SEPARATOR)) { child = new Path(child.uri.getScheme(), child.uri.getAuthority(), child.uri.getPath().substring(1)); } final URI resolved = parentUri.resolve(child.uri); initialize(resolved.getScheme(), resolved.getAuthority(), normalizePath(resolved.getPath())); }