blob: 4c1022b64b9c62ab83b81ac456217a0b8d30081a [file] [log] [blame]
package com.google.gwt.examples.http.client;
import com.google.gwt.http.client.URL;
public class QueryAndFormDataExample {
public static interface Entry {
String getName();
String getValue();
}
public static String buildQueryString(Entry[] queryEntries) {
StringBuffer sb = new StringBuffer();
for (int i = 0, n = queryEntries.length; i < n; ++i) {
Entry queryEntry = queryEntries[i];
if (i > 0) {
sb.append("&");
}
// encode the characters in the name
String encodedName = URL.encodeQueryString(queryEntry.getName());
sb.append(encodedName);
sb.append("=");
// encode the characters in the value
String encodedValue = URL.encodeQueryString(queryEntry.getValue());
sb.append(encodedValue);
}
return sb.toString();
}
}