Java Utililty Methods URI to

List of utility methods to do URI to

Description

The list of methods to do URI to are organized into topic(s).

Method

StringconvertToAbsPath(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();
StringconvertToEncodedURIString(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[] { ' ', '\"', '%', '<', '>', '#', '[', '\\', ']', '^', '`', '{', '|', '}' };
...
URIextractBaseUriFromRDF(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; 
...
MapextractContentDigest(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;
...
URIextractForwardURIFrom(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));
StringextractFromURIParams(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");
...
StringextractHostAddress(String uri)
extract Host Address
URL url = new URL(uri);
return url.getProtocol() + "://" + url.getHost() + ":" + url.getPort();
StringextractHostname(String uri)
extract Hostname
try {
    return extractHostname(new URI(uri));
} catch (URISyntaxException e) {
    throw new IllegalArgumentException(e);
StringextractLocalName(String uri)
extract Local Name
return extractLocalName(URI.create(uri));
URIextractOntologyNameUriFromRDF(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;
...