List of utility methods to do URI Create
InetSocketAddress | getURIAddress(URI uri) get URI Address String host = uri.getHost(); int port = uri.getPort(); return new InetSocketAddress(host, port); |
URI | getUriByEndpoint(String endpoint) Get the URI object for the given endpoint. URI targetEndpointUri = null; try { targetEndpointUri = new URI(endpoint); if (targetEndpointUri.getHost() == null) { targetEndpointUri = new URI("http://" + endpoint); } catch (URISyntaxException e) { throw new RuntimeException("Unable to parse service endpoint: " + e.getMessage()); ... |
String | getURIFilename(final String s) Get the filename of an URI if (s == null) { return null; try { final URI uri = new URI(s); return new File(uri.getPath()).getName(); } catch (URISyntaxException e) { return null; ... |
URI | getURIFromEncodedString(String unencoded) get URI From Encoded String URI uri; String[] split = unencoded.split("\\?"); String part1 = split[0].replaceAll("\\[", URLEncoder.encode("[", "UTF8")) .replaceAll("\\]", URLEncoder.encode("]", "UTF8")) .replaceAll("\\|", URLEncoder.encode("|", "UTF8")); if (split.length < 2) { uri = new URI(part1); } else { ... |
URI | getURIFromPath(String fileOrURI) Get a URI from a string. URI uri = null; try { uri = new URI(fileOrURI); if (uri.getScheme() == null) { uri = new File(fileOrURI).toURI(); } catch (URISyntaxException usx) { uri = new File(fileOrURI).toURI(); ... |
URI | getURIFromPath(String path) get URI From Path URI retUri = null; try { retUri = new URI(path); } catch (URISyntaxException e) { e.printStackTrace(); return retUri; |
String | getURIName(String forwardSlashPath) Path is parsed using '/' as separator. if (forwardSlashPath == null) return null; int end = forwardSlashPath.length(); if (end == 0) return ""; if (forwardSlashPath.charAt(end - 1) == '/') end = end - 1; if (end == 0) ... |
String | getURIName(URI uri) get URI Name File file = new File(uri.getPath()); return file.getName(); |
String | getURIParameterValue(URI uri, String name, String defVal) get URI Parameter Value if (uri == null || name == null) return defVal; final String rawQuery = uri.getRawQuery(); if (rawQuery == null) return defVal; String part; int s = 0; int e = rawQuery.indexOf('&'); ... |
URI[] | getURIs(final Object[] objs) ottengo un array di URI da un array contenente File o URL final List<URI> uris = new LinkedList<URI>(); for (final Object obj : objs) { if (obj instanceof URI) { uris.add((URI) obj); } else if (obj instanceof URL) { uris.add(((URL) obj).toURI()); } else if (obj instanceof File) { uris.add(((File) obj).toURI()); ... |