@Test public void shouldConvertToUrlEncode() throws Exception { String expectedUrlEncoded = "key1=value1&key2=value2"; String urlEncoded = requestMap.toUrlEncode("UTF-8"); assertEquals(expectedUrlEncoded, urlEncoded); }
public String toUrlEncode(String charset) throws UnsupportedEncodingException { StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> entry : map.entrySet()) { if (sb.length() > 0) { sb.append("&"); } sb.append(String.format("%s=%s", URLEncoder.encode(entry.getKey(), charset), URLEncoder.encode(entry.getValue(), charset))); } return sb.toString(); }
RequestMap { public String toUrlEncode(String charset) throws UnsupportedEncodingException { StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> entry : map.entrySet()) { if (sb.length() > 0) { sb.append("&"); } sb.append(String.format("%s=%s", URLEncoder.encode(entry.getKey(), charset), URLEncoder.encode(entry.getValue(), charset))); } return sb.toString(); } }
RequestMap { public String toUrlEncode(String charset) throws UnsupportedEncodingException { StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> entry : map.entrySet()) { if (sb.length() > 0) { sb.append("&"); } sb.append(String.format("%s=%s", URLEncoder.encode(entry.getKey(), charset), URLEncoder.encode(entry.getValue(), charset))); } return sb.toString(); } RequestMap();  RequestMap(Map<String, String> map); }
RequestMap { public String toUrlEncode(String charset) throws UnsupportedEncodingException { StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> entry : map.entrySet()) { if (sb.length() > 0) { sb.append("&"); } sb.append(String.format("%s=%s", URLEncoder.encode(entry.getKey(), charset), URLEncoder.encode(entry.getValue(), charset))); } return sb.toString(); } RequestMap();  RequestMap(Map<String, String> map); RequestMap putMap(RequestMap requestMap); RequestMap putMap(Map<String, String> map); RequestMap putString(String key, String value); RequestMap putString(String key, StringBuilder value); RequestMap putInteger(String key, Integer value); RequestMap putCurrency(String key, BigDecimal value); RequestMap putCurrency(String key, Currency value); RequestMap putDate(String key, Date value, DateFormat dateFormat); RequestMap putConfigValue(String key, Config config); String toUrlEncode(String charset); HttpRequestBody toHttpRequestBody(String charset); @Override String toString(); @Override boolean equals(Object o); }
RequestMap { public String toUrlEncode(String charset) throws UnsupportedEncodingException { StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> entry : map.entrySet()) { if (sb.length() > 0) { sb.append("&"); } sb.append(String.format("%s=%s", URLEncoder.encode(entry.getKey(), charset), URLEncoder.encode(entry.getValue(), charset))); } return sb.toString(); } RequestMap();  RequestMap(Map<String, String> map); RequestMap putMap(RequestMap requestMap); RequestMap putMap(Map<String, String> map); RequestMap putString(String key, String value); RequestMap putString(String key, StringBuilder value); RequestMap putInteger(String key, Integer value); RequestMap putCurrency(String key, BigDecimal value); RequestMap putCurrency(String key, Currency value); RequestMap putDate(String key, Date value, DateFormat dateFormat); RequestMap putConfigValue(String key, Config config); String toUrlEncode(String charset); HttpRequestBody toHttpRequestBody(String charset); @Override String toString(); @Override boolean equals(Object o);  }