@Test public void testCreateQueryEncodesParameters() throws URISyntaxException { final String encodedValue = "%25Ca%2BHn%2Fav"; final String decodedValue = "%Ca+Hn/av"; final String encodedKey = "user%2Bname"; final String decodedKey = "user+name"; Map<String, String> source = new HashMap<String, String>(); source.put(decodedKey, decodedValue); String result = PropertyUtil.createQueryString(source); assertEquals(encodedKey + "=" + encodedValue, result); }
public static String createQueryString(Map<String, ? extends Object> options) throws URISyntaxException { try { if (options.size() > 0) { StringBuffer rc = new StringBuffer(); boolean first = true; for (Entry<String, ? extends Object> entry : options.entrySet()) { if (first) { first = false; } else { rc.append("&"); } rc.append(URLEncoder.encode(entry.getKey(), UTF8)); rc.append("="); rc.append(URLEncoder.encode((String) entry.getValue(), UTF8)); } return rc.toString(); } else { return ""; } } catch (UnsupportedEncodingException e) { throw (URISyntaxException) new URISyntaxException(e.toString(), "Invalid encoding").initCause(e); } }
PropertyUtil { public static String createQueryString(Map<String, ? extends Object> options) throws URISyntaxException { try { if (options.size() > 0) { StringBuffer rc = new StringBuffer(); boolean first = true; for (Entry<String, ? extends Object> entry : options.entrySet()) { if (first) { first = false; } else { rc.append("&"); } rc.append(URLEncoder.encode(entry.getKey(), UTF8)); rc.append("="); rc.append(URLEncoder.encode((String) entry.getValue(), UTF8)); } return rc.toString(); } else { return ""; } } catch (UnsupportedEncodingException e) { throw (URISyntaxException) new URISyntaxException(e.toString(), "Invalid encoding").initCause(e); } } }
PropertyUtil { public static String createQueryString(Map<String, ? extends Object> options) throws URISyntaxException { try { if (options.size() > 0) { StringBuffer rc = new StringBuffer(); boolean first = true; for (Entry<String, ? extends Object> entry : options.entrySet()) { if (first) { first = false; } else { rc.append("&"); } rc.append(URLEncoder.encode(entry.getKey(), UTF8)); rc.append("="); rc.append(URLEncoder.encode((String) entry.getValue(), UTF8)); } return rc.toString(); } else { return ""; } } catch (UnsupportedEncodingException e) { throw (URISyntaxException) new URISyntaxException(e.toString(), "Invalid encoding").initCause(e); } }  }
PropertyUtil { public static String createQueryString(Map<String, ? extends Object> options) throws URISyntaxException { try { if (options.size() > 0) { StringBuffer rc = new StringBuffer(); boolean first = true; for (Entry<String, ? extends Object> entry : options.entrySet()) { if (first) { first = false; } else { rc.append("&"); } rc.append(URLEncoder.encode(entry.getKey(), UTF8)); rc.append("="); rc.append(URLEncoder.encode((String) entry.getValue(), UTF8)); } return rc.toString(); } else { return ""; } } catch (UnsupportedEncodingException e) { throw (URISyntaxException) new URISyntaxException(e.toString(), "Invalid encoding").initCause(e); } }  static URI replaceQuery(URI originalURI, Map<String, String> properties); static URI replaceQuery(URI uri, String query); static URI eraseQuery(URI uri); static String createQueryString(Map<String, ? extends Object> options); static Map<String, String> parseQuery(URI uri); static Map<String, String> parseQuery(String queryString); static Map<String, String> filterProperties(Map<String, String> properties, String optionPrefix); static Map<String, String> setProperties(Object target, Map<String, String> properties); static Map<String, Object> setProperties(Object target, Properties properties); static Map<String, String> getProperties(Object object); static Object getProperty(Object object, String name); static boolean setProperty(Object target, String name, Object value); static String stripPrefix(String value, String prefix); static String stripUpto(String value, char c); static String stripBefore(String value, char c); }
PropertyUtil { public static String createQueryString(Map<String, ? extends Object> options) throws URISyntaxException { try { if (options.size() > 0) { StringBuffer rc = new StringBuffer(); boolean first = true; for (Entry<String, ? extends Object> entry : options.entrySet()) { if (first) { first = false; } else { rc.append("&"); } rc.append(URLEncoder.encode(entry.getKey(), UTF8)); rc.append("="); rc.append(URLEncoder.encode((String) entry.getValue(), UTF8)); } return rc.toString(); } else { return ""; } } catch (UnsupportedEncodingException e) { throw (URISyntaxException) new URISyntaxException(e.toString(), "Invalid encoding").initCause(e); } }  static URI replaceQuery(URI originalURI, Map<String, String> properties); static URI replaceQuery(URI uri, String query); static URI eraseQuery(URI uri); static String createQueryString(Map<String, ? extends Object> options); static Map<String, String> parseQuery(URI uri); static Map<String, String> parseQuery(String queryString); static Map<String, String> filterProperties(Map<String, String> properties, String optionPrefix); static Map<String, String> setProperties(Object target, Map<String, String> properties); static Map<String, Object> setProperties(Object target, Properties properties); static Map<String, String> getProperties(Object object); static Object getProperty(Object object, String name); static boolean setProperty(Object target, String name, Object value); static String stripPrefix(String value, String prefix); static String stripUpto(String value, char c); static String stripBefore(String value, char c);  }