List of usage examples for com.google.gwt.http.client URL encodeComponent
@Deprecated public static String encodeComponent(String decodedURLComponent)
From source file:org.waveprotocol.wave.client.gadget.renderer.GadgetWidget.java
License:Apache License
/** * Utility function to convert a Gadget StateMap to a string to be stored as * an attribute value.//from ww w. java 2 s .co m * * @param state JSON object to be converted to string. * @return string to be saved as an attribute value. */ private static String stateToAttribute(StateMap state) { if (state == null) { return URL.encodeComponent("{}"); } return URL.encodeComponent(state.toJson()); }
From source file:org.waveprotocol.wave.client.gadget.renderer.GadgetWidget.java
License:Apache License
/** * Appends tokens to the iframe URI fragment. * * @param fragment Original parameter fragment of the gadget URI. * @return Updated parameter fragment with new RPC and security tokens. *//*ww w. j av a 2 s.c o m*/ private String updateGadgetUriFragment(String fragment) { fragment = "rpctoken=" + rpcToken + (fragment.isEmpty() || (fragment.charAt(0) == '&') ? "" : "&") + fragment; if ((securityToken != null) && !securityToken.isEmpty()) { fragment += "&st=" + URL.encodeComponent(securityToken); } return fragment; }
From source file:org.waveprotocol.wave.client.util.UrlParameters.java
License:Apache License
/** * Build a query string out of a map of key/value pairs. * @param queryEntries/*w w w . j av a 2s.c om*/ */ public static String buildQueryString(Map<String, String> queryEntries) { StringBuffer sb = new StringBuffer(); boolean firstIteration = true; for (Entry<String, String> e : queryEntries.entrySet()) { if (firstIteration) { sb.append('?'); } else { sb.append('&'); } String encodedName = URL.encodeComponent(e.getKey()); sb.append(encodedName); sb.append('='); String encodedValue = URL.encodeComponent(e.getValue()); sb.append(encodedValue); firstIteration = false; } return sb.toString(); }
From source file:rocket.dom.client.Dom.java
License:Apache License
/** * Encodes all the elements belonging to form into a safe url encoded * String.//from w ww .ja v a 2s . c om * * @param form * @return */ public static String urlEncodeForm(final FormElement form) { Checker.notNull("parameter:form", form); final StringBuffer urlEncoded = new StringBuffer(); boolean addSeparator = false; final NodeCollection<Element> formElements = form.getElements(); final int count = formElements.getLength(); for (int i = 0; i < count; i++) { final Element element = formElements.getItem(i); final String name = element.getAttribute(DomConstants.NAME); if (null == name) { continue; } if (addSeparator) { urlEncoded.append('&'); } final String value = URL.encodeComponent(Dom.getFormSubmitValue(element)); urlEncoded.append(name); urlEncoded.append('='); urlEncoded.append(value); addSeparator = true; } return urlEncoded.toString(); }
From source file:rocket.remoting.client.RequestParameters.java
License:Apache License
/** * Converts the parameters within this object into a post data equivalent ie * array of bytes.// w ww . jav a2 s . co m * * @return The built string. */ public String asString() { final StringBuffer data = new StringBuffer(); final Iterator<String> names = this.names(); boolean addSeparator = false; while (names.hasNext()) { final String name = (String) names.next(); final List<String> valuesList = this.getValueAsList(name); if (null == valuesList) { continue; } final Iterator<String> values = valuesList.iterator(); while (values.hasNext()) { if (addSeparator) { data.append("&"); } addSeparator = true; data.append(name); data.append('='); data.append(URL.encodeComponent(values.next())); } } return data.toString(); }