List of utility methods to do URI to
String | convertToAbsPath(URI baseURI, String path) convert To Abs Path if (path == null || path.isEmpty()) { return path; File absFile = new File(baseURI.resolve(path)); return absFile.getCanonicalPath(); |
String | convertToEncodedURIString(String input) This method replace non-URI-valid characters with their replacement code counterpart (issue PROACTIVE-1314) StringBuilder answer = new StringBuilder(); try { input = URLDecoder.decode(input, "UTF8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return null; char[] inputChars = new char[] { ' ', '\"', '%', '<', '>', '#', '[', '\\', ']', '^', '`', '{', '|', '}' }; ... |
URI | extractBaseUriFromRDF(String rdfString) Parses a RDF/XML-serialization and returns the base-URI if a value for 'xml:base' was set, null otherwise.
int startPos = -1; int endPos = -1; startPos = rdfString.indexOf("xml:base=\"") + 10; if (startPos > 10) { endPos = rdfString.indexOf("\"", startPos + 1); } else { startPos = rdfString.indexOf("xmlns=\"") + 7; endPos = rdfString.indexOf("\"", startPos + 1) - 1; ... |
Map | extractContentDigest(URI contentDigest) extract Content Digest Map<String, String> ret = new HashMap<>(); if (contentDigest != null) { final String[] values = contentDigest.getSchemeSpecificPart().split(":"); if (values.length == 2) { ret.put(values[0], values[1]); return ret; ... |
URI | extractForwardURIFrom(URI requestURI) If no forward URI is given then return null. int http = requestURI.toString().indexOf("http", 4); if (http == -1) return null; return URI.create(requestURI.toString().substring(http)); |
String | extractFromURIParams(String paramsRule, String uri) Extract and build a dispatch criteria string from URI parameters Map<String, String> criteriaMap = new TreeMap<String, String>(); if (uri.contains("?") && uri.contains("=")) { String parameters = uri.substring(uri.indexOf("?") + 1); for (String parameter : parameters.split("&")) { String[] pair = parameter.split("="); try { String key = URLDecoder.decode(pair[0], "UTF-8"); String value = URLDecoder.decode(pair[1], "UTF-8"); ... |
String | extractHostAddress(String uri) extract Host Address URL url = new URL(uri); return url.getProtocol() + "://" + url.getHost() + ":" + url.getPort(); |
String | extractHostname(String uri) extract Hostname try { return extractHostname(new URI(uri)); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); |
String | extractLocalName(String uri) extract Local Name return extractLocalName(URI.create(uri));
|
URI | extractOntologyNameUriFromRDF(String rdfString, boolean generateURI) Parses a RDF/XML-serialization and returns the base-URI if a value for 'xml:base' was set, null otherwise.
int startPos = -1; int endPos = -1; String uri = null; startPos = rdfString.indexOf("xml:base=\"") + 10; endPos = rdfString.indexOf("\"", startPos + 1); uri = rdfString.substring(startPos, endPos); if (startPos == 9) { startPos = rdfString.indexOf("xmlns=\"") + 7; ... |