Example usage for com.google.gwt.http.client URL decode

List of usage examples for com.google.gwt.http.client URL decode

Introduction

In this page you can find the example usage for com.google.gwt.http.client URL decode.

Prototype

public static String decode(String encodedURL) 

Source Link

Document

Returns a string where all URL escape sequences have been converted back to their original character representations.

Usage

From source file:com.sencha.gxt.core.client.util.Format.java

License:sencha.com license

/**
 * Convert certain characters (&, <, >, and ') from their HTML character
 * equivalents./*from  w w w .  j  ava  2 s.co m*/
 * 
 * @param value the value
 * @return the decoded value
 */
public static String htmlDecode(String value) {
    return URL.decode(value);
}

From source file:com.tasktop.c2c.server.common.web.client.navigation.Navigation.java

License:Open Source License

/**
 * get request parameters that were passed on the {@link History#getToken() history token}. The history token is
 * used for parameters so that the page doesn't have to reload.
 *///from  w  w  w.j  a v a 2  s.com
public static Map<String, List<String>> getNavigationParameterMap() {
    Map<String, List<String>> parameters = new HashMap<String, List<String>>();

    String currentToken = History.getToken();
    if (currentToken != null) {
        int idxOfQueryStringSeparator = currentToken.indexOf('?');
        if (idxOfQueryStringSeparator != -1 && idxOfQueryStringSeparator < (currentToken.length() - 1)) {
            String queryString = currentToken.substring(idxOfQueryStringSeparator + 1);
            String[] parts = queryString.split("&");
            for (String part : parts) {
                String[] keyValue = part.split("=");
                if (keyValue.length == 2) {
                    String key = URL.decode(keyValue[0]);
                    String value = URL.decode(keyValue[1]);
                    List<String> values = parameters.get(key);
                    if (values == null) {
                        values = new ArrayList<String>(1);
                        parameters.put(key, values);
                    }
                    values.add(value);
                }
            }
        }
    }
    return parameters;
}

From source file:com.tasktop.c2c.server.common.web.shared.URLEncoding.java

License:Open Source License

/**
 * decode the given URI part. When {@link GWT#isClient() is client = true}, GWT client URL decoding is used.
 *///from w  ww .  j  av  a2  s . c  om
public static String decode(String part) {
    if (GWT.isClient()) {
        return URL.decode(part.replace("+", "%20"));
    }
    StringBuilder result = new StringBuilder(part.length() + 10);
    for (int x = 0; x < part.length(); ++x) {
        // see http://en.wikipedia.org/wiki/Percent-encoding
        char c = part.charAt(x);
        if (isUnreserved(c)) {
            result.append(c);
        } else {
            if (c == '+') {
                c = ' ';
            } else if (c == '%') {
                c = (char) Integer.parseInt("" + part.charAt(++x) + part.charAt(++x), 16);
            }
            result.append(c);
        }
    }
    return result.toString();
}

From source file:com.vaadin.client.ui.FontIcon.java

License:Apache License

@Override
public void setUri(String uri) {
    String[] parts = uri.substring(ApplicationConstants.FONTICON_PROTOCOL_PREFIX.length()).split("/");
    setFontFamily(URL.decode(parts[0]));
    setCodepoint(Integer.parseInt(parts[1], 16));
}

From source file:es.deusto.weblab.client.HistoryProperties.java

License:Open Source License

public static void reloadHistory() {
    values.clear();/* ww  w  .j  av a  2s.c  o m*/
    String currentToken = History.getToken();
    for (String token : currentToken.split("&")) {
        final String key = token.split("=")[0];
        final String value;
        if (!token.contains("="))
            value = "";
        else {
            value = URL.decode(token.substring(token.indexOf('=') + 1));
        }

        if (values.containsKey(key)) {
            final String[] oldValue = values.get(key);
            final String[] newValue = new String[oldValue.length + 1];
            for (int i = 0; i < oldValue.length; ++i)
                newValue[i] = oldValue[i];
            newValue[newValue.length - 1] = key;
        } else if (!key.isEmpty())
            values.put(key, new String[] { value });
    }
}

From source file:es.deusto.weblab.client.HistoryProperties.java

License:Open Source License

public static String decode(String encoded) {
    String text = encoded.replace("%3A", ":");
    text = text.replace("%2F", "/");
    text = text.replace("%23", "#");
    text = text.replace("%26", "&");
    text = text.replace("%3D", "=");
    return URL.decode(text);
}

From source file:io.reinert.requestor.uri.UriParser.java

License:Apache License

public UriParser parse(String uri) {
    if (uri == null || uri.isEmpty())
        throw new UriParseException("The uri argument cannot be null or empty");

    resetParser();//w  w  w.jav  a  2 s.co m

    String parsedUri = uri;
    String query;
    int pos;

    // Extract fragment
    pos = parsedUri.indexOf('#');
    if (pos > -1) {
        // Check last char
        fragment = parsedUri.length() - pos == 1 ? null : URL.decode(parsedUri.substring(pos + 1));
        // Remove parsed part from parsing uri
        parsedUri = parsedUri.substring(0, pos);
    }

    // Extract query
    pos = parsedUri.indexOf('?');
    if (pos > -1) {
        // Check last char
        query = parsedUri.length() - pos == 1 ? null : parsedUri.substring(pos + 1);
        parseQuery(query);
        // Remove parsed part from parsing uri
        parsedUri = parsedUri.substring(0, pos);
    }

    // Extract protocol
    if (parsedUri.length() > 2 && parsedUri.substring(0, 2).equals("//")) {
        // Relative-Scheme
        scheme = null;
        parsedUri = parsedUri.substring(2);
        // Extract "user:pass@host:port"
        parsedUri = parseAuthority(parsedUri);
    } else {
        pos = parsedUri.indexOf("://");
        if (pos > -1) {
            scheme = pos > 0 ? parsedUri.substring(0, pos) : null;
            parsedUri = parsedUri.substring(pos + 3);

            // Extract "user:pass@host:port"
            parsedUri = parseAuthority(parsedUri);
        }
    }

    // The left part must be the path
    final List<String> parsedSegments = new ArrayList<String>();
    final String[] rawSegments = parsedUri.split("/");
    for (String segment : rawSegments) {
        if (!segment.isEmpty()) {
            String[] matrixParts = segment.split(";");
            final String parsedSegment = URL.decode(matrixParts[0]);
            parsedSegments.add(parsedSegment);
            if (matrixParts.length > 1) {
                if (matrixParams == null) {
                    matrixParams = GWT.create(LightMap.class);
                }
                final Buckets buckets = GWT.create(Buckets.class);
                matrixParams.put(parsedSegment, buckets);
                for (int i = 1; i < matrixParts.length; i++) {
                    String[] matrixElements = matrixParts[i].split("=");
                    if (matrixElements.length == 1) {
                        buckets.add(URL.decode(matrixElements[0]), null);
                    } else {
                        buckets.add(URL.decode(matrixElements[0]), URL.decode(matrixElements[1]));
                    }
                }
            }
        }
    }
    this.segments = parsedSegments.toArray(new String[parsedSegments.size()]);

    return this;
}

From source file:io.reinert.requestor.uri.UriParser.java

License:Apache License

private String parseUserInfo(String uri) {
    // Extract username:password
    int pathDivider = uri.indexOf('/');
    int pos = uri.lastIndexOf('@', pathDivider > -1 ? pathDivider : uri.length() - 1);

    // authority@ must come before /path
    if (pos > -1 && (pathDivider == -1 || pos < pathDivider)) {
        String[] t = uri.substring(0, pos).split(":");
        user = !t[0].isEmpty() ? URL.decode(t[0]) : null;
        password = t.length > 1 && !t[1].isEmpty() ? URL.decode(t[1]) : null;
        uri = uri.substring(pos + 1);/*ww w .j  a  v  a  2s .  co m*/
    } else {
        user = null;
        password = null;
    }

    return uri;
}

From source file:nl.mpi.tg.eg.experiment.client.service.ObfuscatedStorage.java

License:Open Source License

private String revealString(String storageKey, String input) {
    return URL.decode(processString(storageKey, input).trim());
}

From source file:org.chromium.distiller.DomUtil.java

License:Open Source License

/**
 * Split URL parameters into key/value pairs and return them in a map.
 * @param query The query string after the "?".
 * @return Map of all query parameters or an empty map.
 *///from   w  ww  . j  a  va 2 s.com
public static Map<String, String> splitUrlParams(String query) {
    if (query == null || query.isEmpty()) {
        return new HashMap<>();
    }
    Map<String, String> paramMap = new HashMap<>();
    String[] params = query.split("&");
    for (int i = 0; i < params.length; i++) {
    }
    for (String currentParam : params) {
        String[] paramSplit = currentParam.split("=");
        if (paramSplit.length > 1) {
            paramMap.put(paramSplit[0], URL.decode(paramSplit[1]));
        }
    }
    return paramMap;
}