List of utility methods to do URI to Relative URI
URI | getRedirectUri(URI uri, String location) get Redirect Uri URI newUri = uri.resolve(location); String scheme = newUri.getScheme(); if (scheme == null || !scheme.equalsIgnoreCase("http") && !scheme.equalsIgnoreCase("https")) { throw new IllegalArgumentException("The URI scheme, of the URI " + newUri + ", must be equal (ignoring case) to 'http' or 'https'"); return newUri; |
URI | getRelativeLocalURI(String suffix) Now works for both linux and windows return URI.create("file:///" + getCurrentDir().replace("\\", "/") + suffix); |
String | getRelativeName(File file, URI directory) get Relative Name URI fUri = file.toURI();
return directory.relativize(fUri).getPath();
|
String | getRelativePath(URI base, File file) Return the path for the file relative to the base uri. return toString(getRelativeURI(base, file.toURI()));
|
URI | getRelativePath(URI targetURI, URI baseURI) Returns a relative path between basePath and targetPath if possible. if (!targetURI.isAbsolute() || !baseURI.isAbsolute() || targetURI.isOpaque() || baseURI.isOpaque()) return targetURI; if (!targetURI.getScheme().equals(baseURI.getScheme())) return targetURI; String basePath = baseURI.getPath().substring(1); String targetPath = targetURI.getPath().substring(1); String[] base = basePath.split("/", -1); String[] target = targetPath.split("/", 0); ... |
String | getRelativePath(URI targetUri, URI baseUri) Finds the relative path from the baseUri to the target URI. String pathSeparator = "/"; String targetPath = targetUri.getPath(); String[] base; String[] target; if (baseUri.toString().startsWith("jar:")) { try { JarURLConnection conn = (JarURLConnection) (baseUri.toURL().openConnection()); String entryName = conn.getEntryName(); ... |
String | getRelativeURI(String href) Returns the relative URI of the href argument if (href == null) return href; int idx = -1; try { new URL(href); idx = href.lastIndexOf(HREF_PATH_SEP); } catch (MalformedURLException muex) { int idx2 = href.lastIndexOf(HREF_PATH_SEP); ... |
URI | getRelativeURI(URI base, URI uri) Return the uri for the uri relative to the base uri. if (base != null && uri != null && (uri.getScheme() == null || uri.getScheme().equals(base.getScheme()))) { StringTokenizer baseParts = tokenizeBase(base); StringTokenizer uriParts = new StringTokenizer(uri.getSchemeSpecificPart(), "/"); StringBuffer relativePath = new StringBuffer(); String part = null; boolean first = true; if (!baseParts.hasMoreTokens()) { return uri; ... |
URI | getRelativeURI(URI repositoryXml, URI bundleJar) get Relative URI try { String repositoryPath = repositoryXml.getPath(); if (repositoryPath.toLowerCase().endsWith(DOT_XML)) { int dirnameIndex = repositoryPath.lastIndexOf('/'); repositoryPath = repositoryPath.substring(0, dirnameIndex); URI rootURI = new URI(null, repositoryPath, null); URI localURI = new URI(null, bundleJar.getPath(), null); ... |
URI | getRelativeUri(URI rootURI, File file) get Relative Uri if (file == null) { return null; URI uri = file.toURI(); if (rootURI == null) { return uri; return rootURI.relativize(uri); ... |