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

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

Introduction

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

Prototype

public static String encodeQueryString(String decodedURLComponent) 

Source Link

Document

Returns a string where all characters that are not valid for a URL component have been escaped.

Usage

From source file:com.google.walkaround.wave.client.rpc.AjaxRpc.java

License:Open Source License

private StringBuilder addParams(final StringBuilder b, ReadableStringMap<String> params) {
    params.each(new StringMap.ProcV<String>() {
        @Override/*from   ww  w.  jav  a2s .c o  m*/
        public void apply(String key, String value) {
            if (value != null) {
                b.append(URL.encodeQueryString(key) + "=" + URL.encodeQueryString(value) + "&");
            }
        }
    });
    return b;
}

From source file:com.google.zxing.web.generator.client.Generator.java

License:Apache License

private static String getUrl(int sizeX, int sizeY, String ecLevel, String encoding, String content) {
    StringBuilder result = new StringBuilder(100);
    result.append("http://zxing.org/w/chart?cht=qr");
    result.append("&chs=").append(sizeX).append('x').append(sizeY);
    result.append("&chld=").append(ecLevel);
    result.append("&choe=").append(encoding);
    result.append("&chl=").append(URL.encodeQueryString(content));
    return result.toString();
}

From source file:com.googlesource.gerrit.plugins.xdocs.client.XDocApi.java

License:Apache License

public static String getUrl(String projectName, String revision, String path) {
    StringBuilder url = new StringBuilder();
    url.append("plugins/");
    url.append(Plugin.get().getName());//from ww  w.  j a v  a  2s.  c  om
    url.append("/project/");
    url.append(URL.encodeQueryString(projectName));
    if (revision != null && !"HEAD".equals(revision)) {
        url.append("/rev/");
        url.append(URL.encodeQueryString(revision));
    }
    url.append("/");
    url.append(path);
    url.append("?formatImage");
    return url.toString();
}

From source file:com.gwtcx.client.presenter.AbstractAccountsPresenter.java

License:Open Source License

public void onExportButtonClicked() {

    StringBuilder url = new StringBuilder();
    url.append(DEFAULT_FILE_DOWNLOAD_SERVICE_PATH).append(FILE_DOWNLOAD_HOST_FILENAME).append("?");

    String arg0Name = URL.encodeQueryString(RECORD_TYPE);
    url.append(arg0Name);/*  w w w . j ava 2s.c o m*/
    url.append("=");
    String arg0Value = URL.encodeQueryString("Account");
    url.append(arg0Value);
    // url.append(encodeBase64(arg0Value));

    Log.debug("Window.open() getRelativeURL: " + GwtCxEntryPoint.getRelativeURL(url.toString()));
    Window.open(GwtCxEntryPoint.getRelativeURL(url.toString()), NAME, FEATURES);
}

From source file:com.gwtcx.client.presenter.AbstractPagingPresenter.java

License:Open Source License

public static void openHostFile(String filename, String queryString, String id, String features) {

    StringBuilder url = new StringBuilder();
    url.append(filename).append("?");

    String arg0Name = URL.encodeQueryString(ID);
    url.append(arg0Name);/*from ww  w .ja  v  a  2 s. c o  m*/
    url.append("=");
    String arg0Value = URL.encodeQueryString(id);
    url.append(GwtCxEntryPoint.encodeBase64(arg0Value));
    Log.debug("Window.open() arg0Value: " + arg0Value + " Base64: " + GwtCxEntryPoint.encodeBase64(arg0Value));
    url.append(PARAMETER_SEPERATOR);

    String arg1Name = URL.encodeQueryString(ACTIVITY);
    url.append(arg1Name);
    url.append("=");
    String arg1Value = URL.encodeQueryString(queryString);
    url.append(GwtCxEntryPoint.encodeBase64(arg1Value));
    Log.debug("Window.open() arg1Value: " + arg1Value + " Base64: " + GwtCxEntryPoint.encodeBase64(arg1Value));

    Window.open(GwtCxEntryPoint.getRelativeURL(url.toString()), NAME, features);
}

From source file:com.gwtcx.client.presenter.AbstractReportsPresenter.java

License:Open Source License

public void onRecordDoubleClicked(String reportFilename) {

    StringBuilder url = new StringBuilder();
    url.append(DEFAULT_REPORTS_SERVICE_PATH).append(HOST_FILENAME).append("?");

    String arg0Name = URL.encodeQueryString(REPORT_FILENAME);
    url.append(arg0Name);//  w  w  w . j a  v  a2  s  .  c o m
    url.append("=");
    String arg0Value = URL.encodeQueryString(reportFilename);
    url.append(arg0Value);

    Window.open(GwtCxEntryPoint.getRelativeURL(url.toString()), NAME, FEATURES);
}

From source file:com.gwtplatform.common.client.ClientUrlUtils.java

License:Apache License

@Override
public String encodeQueryString(String decodedUrlComponent) {
    return URL.encodeQueryString(decodedUrlComponent);
}

From source file:com.gwtplatform.mvp.client.proxy.ParameterTokenFormatter.java

License:Apache License

/**
 * This constructor makes it possible to use custom separators in your token formatter. The
 * separators must be 1-letter strings, they must all be different from one another, and they
 * must be encoded when ran through {@link URL#encodeQueryString(String)}).
 *
 * @param hierarchySeparator The symbol used to separate {@link PlaceRequest} in a hierarchy.
 *                           Must be a 1-character string and can't be {@code %}.
 * @param paramSeparator     The symbol used to separate parameters in a {@link PlaceRequest}. Must
 *                           be a 1-character string and can't be {@code %}.
 * @param valueSeparator     The symbol used to separate the parameter name from its value. Must be
 *                           a 1-character string and can't be {@code %}.
 *///from  www .j  a v  a2 s.  c  o  m
public ParameterTokenFormatter(String hierarchySeparator, String paramSeparator, String valueSeparator) {
    assert hierarchySeparator.length() == 1;
    assert paramSeparator.length() == 1;
    assert valueSeparator.length() == 1;
    assert !hierarchySeparator.equals(paramSeparator);
    assert !hierarchySeparator.equals(valueSeparator);
    assert !paramSeparator.equals(valueSeparator);
    assert !valueSeparator.equals(URL.encodeQueryString(valueSeparator));
    assert !hierarchySeparator.equals(URL.encodeQueryString(hierarchySeparator));
    assert !paramSeparator.equals(URL.encodeQueryString(paramSeparator));
    assert !hierarchySeparator.equals("%");
    assert !paramSeparator.equals("%");
    assert !valueSeparator.equals("%");

    this.hierarchySeparator = hierarchySeparator;
    this.paramSeparator = paramSeparator;
    this.valueSeparator = valueSeparator;
}

From source file:com.gwtplatform.mvp.client.proxy.ParameterTokenFormatter.java

License:Apache License

/**
 * Use our custom escaping mechanism to escape the provided string. This should be used on the
 * name token, and the parameter keys and values, before they are attached with the various
 * separators. The string will also be passed through {@link URL#encodeQueryString}.
 * Visible for testing.// w w  w. j  av a 2s.  c  om
 *
 * @param string The string to escape.
 * @return The escaped string.
 */
String customEscape(String string) {
    StringBuilder builder = new StringBuilder();
    int len = string.length();

    char hierarchyChar = hierarchySeparator.charAt(0);
    char paramChar = paramSeparator.charAt(0);
    char valueChar = valueSeparator.charAt(0);

    for (int i = 0; i < len; i++) {
        char ch = string.charAt(i);
        if (ch == ESCAPE_CHARACTER) {
            builder.append(ESCAPED_ESCAPE_CHAR);
        } else if (ch == hierarchyChar) {
            builder.append(ESCAPED_HIERARCHY_SEPARATOR);
        } else if (ch == paramChar) {
            builder.append(ESCAPED_PARAM_SEPARATOR);
        } else if (ch == valueChar) {
            builder.append(ESCAPED_VALUE_SEPARATOR);
        } else {
            builder.append(ch);
        }
    }

    return URL.encodeQueryString(builder.toString());
}

From source file:com.gwtplatform.mvp.client.proxy.ParameterTokenFormatterOld.java

License:Apache License

/**
 * This constructor makes it possible to use custom separators in your token
 * formatter. The separators must be 1-letter strings, they must all be
 * different from one another, and they must be encoded when ran through
 * {@link URL#encodeQueryString(String)})
 *
 * @param hierarchySeparator The symbol used to separate {@link PlaceRequest}
 *                           in a hierarchy. Must be a 1-character string and can't be {@code %}.
 * @param paramSeparator     The symbol used to separate parameters in a
 *                           {@link PlaceRequest}. Must be a 1-character string and can't be {@code %}.
 * @param valueSeparator     The symbol used to separate the parameter name from
 *                           its value. Must be a 1-character string and can't be {@code %}.
 */// www.  java2  s .c om
public ParameterTokenFormatterOld(String hierarchySeparator, String paramSeparator, String valueSeparator) {

    assert hierarchySeparator.length() == 1;
    assert paramSeparator.length() == 1;
    assert valueSeparator.length() == 1;
    assert !hierarchySeparator.equals(paramSeparator);
    assert !hierarchySeparator.equals(valueSeparator);
    assert !paramSeparator.equals(valueSeparator);
    assert !valueSeparator.equals(URL.encodeQueryString(valueSeparator));
    assert !hierarchySeparator.equals(URL.encodeQueryString(hierarchySeparator));
    assert !paramSeparator.equals(URL.encodeQueryString(paramSeparator));
    assert !hierarchySeparator.equals("%");
    assert !paramSeparator.equals("%");
    assert !valueSeparator.equals("%");

    this.hierarchySeparator = hierarchySeparator;
    this.paramSeparator = paramSeparator;
    this.valueSeparator = valueSeparator;
}