@Test public void toStringTest() { Map<String, String> map = new LinkedHashMap<String, String>(); assertEquals("", DictUtil.toString(map)); map.put("key1", "val1"); assertEquals("key1=val1", DictUtil.toString(map)); map.put("key2", "val 2"); assertEquals("key1=val1&key2=val+2", DictUtil.toString(map)); map.clear(); map.put("key", null); assertEquals("value missing parse test mismatch", "key", DictUtil.toString(map)); map.clear(); map.put("key", ""); assertEquals("empty value parse test mismatch", "key=", DictUtil.toString(map)); }
public static String toString(Map<String, String> map) { StringBuilder sb = new StringBuilder(); for (Iterator<Map.Entry<String, String>> i = map.entrySet().iterator(); i.hasNext();) { Map.Entry<String, String> entry = i.next(); if (entry.getValue() == null) { sb.append(urlEncode(entry.getKey())); } else { sb.append(urlEncode(entry.getKey())).append("=").append(urlEncode(entry.getValue())); } if (i.hasNext()) { sb.append("&"); } } return sb.toString(); }
DictUtil { public static String toString(Map<String, String> map) { StringBuilder sb = new StringBuilder(); for (Iterator<Map.Entry<String, String>> i = map.entrySet().iterator(); i.hasNext();) { Map.Entry<String, String> entry = i.next(); if (entry.getValue() == null) { sb.append(urlEncode(entry.getKey())); } else { sb.append(urlEncode(entry.getKey())).append("=").append(urlEncode(entry.getValue())); } if (i.hasNext()) { sb.append("&"); } } return sb.toString(); } }
DictUtil { public static String toString(Map<String, String> map) { StringBuilder sb = new StringBuilder(); for (Iterator<Map.Entry<String, String>> i = map.entrySet().iterator(); i.hasNext();) { Map.Entry<String, String> entry = i.next(); if (entry.getValue() == null) { sb.append(urlEncode(entry.getKey())); } else { sb.append(urlEncode(entry.getKey())).append("=").append(urlEncode(entry.getValue())); } if (i.hasNext()) { sb.append("&"); } } return sb.toString(); }  }
DictUtil { public static String toString(Map<String, String> map) { StringBuilder sb = new StringBuilder(); for (Iterator<Map.Entry<String, String>> i = map.entrySet().iterator(); i.hasNext();) { Map.Entry<String, String> entry = i.next(); if (entry.getValue() == null) { sb.append(urlEncode(entry.getKey())); } else { sb.append(urlEncode(entry.getKey())).append("=").append(urlEncode(entry.getValue())); } if (i.hasNext()) { sb.append("&"); } } return sb.toString(); }  static Map<String, String> parse(String query); static Map<String, String> parse(String query, Map<String, String> map); static Map<String, String> parseParam(String str, Map<String, String> map); static String toString(Map<String, String> map); static Multidict asMultidict(Dict dict); }
DictUtil { public static String toString(Map<String, String> map) { StringBuilder sb = new StringBuilder(); for (Iterator<Map.Entry<String, String>> i = map.entrySet().iterator(); i.hasNext();) { Map.Entry<String, String> entry = i.next(); if (entry.getValue() == null) { sb.append(urlEncode(entry.getKey())); } else { sb.append(urlEncode(entry.getKey())).append("=").append(urlEncode(entry.getValue())); } if (i.hasNext()) { sb.append("&"); } } return sb.toString(); }  static Map<String, String> parse(String query); static Map<String, String> parse(String query, Map<String, String> map); static Map<String, String> parseParam(String str, Map<String, String> map); static String toString(Map<String, String> map); static Multidict asMultidict(Dict dict);  }