@Test public void testGetRequestParameters() { assertEquals(parameters, URIUtils.getRequestParameters(URI_QUERY)); assertEquals(parameters, URIUtils.getRequestParameters(PARTIAL_URI)); }
public static Map<String, String> getRequestParameters(String uriQuery) { Map<String, String> parameters = null; if (uriQuery != null && uriQuery.length() > 0) { try { String strippedQuery; int index = uriQuery.indexOf('?'); if (index != -1) { strippedQuery = uriQuery.substring(index + 1); } else { strippedQuery = uriQuery; } String[] items = strippedQuery.split("&"); if (items.length > 0) { parameters = new LinkedHashMap<>(); for (String item : items) { String[] param = item.split("="); if (param.length == 2) { parameters.put(URLDecoder.decode(param[0], "UTF-8"), URLDecoder.decode(param[1], "UTF-8")); } else if (param.length == 1) { parameters.put(URLDecoder.decode(param[0], "UTF-8"), null); } } } } catch (UnsupportedEncodingException e) { log.error("Failed to get request parameters from uri", e); } } return parameters; }
URIUtils { public static Map<String, String> getRequestParameters(String uriQuery) { Map<String, String> parameters = null; if (uriQuery != null && uriQuery.length() > 0) { try { String strippedQuery; int index = uriQuery.indexOf('?'); if (index != -1) { strippedQuery = uriQuery.substring(index + 1); } else { strippedQuery = uriQuery; } String[] items = strippedQuery.split("&"); if (items.length > 0) { parameters = new LinkedHashMap<>(); for (String item : items) { String[] param = item.split("="); if (param.length == 2) { parameters.put(URLDecoder.decode(param[0], "UTF-8"), URLDecoder.decode(param[1], "UTF-8")); } else if (param.length == 1) { parameters.put(URLDecoder.decode(param[0], "UTF-8"), null); } } } } catch (UnsupportedEncodingException e) { log.error("Failed to get request parameters from uri", e); } } return parameters; } }
URIUtils { public static Map<String, String> getRequestParameters(String uriQuery) { Map<String, String> parameters = null; if (uriQuery != null && uriQuery.length() > 0) { try { String strippedQuery; int index = uriQuery.indexOf('?'); if (index != -1) { strippedQuery = uriQuery.substring(index + 1); } else { strippedQuery = uriQuery; } String[] items = strippedQuery.split("&"); if (items.length > 0) { parameters = new LinkedHashMap<>(); for (String item : items) { String[] param = item.split("="); if (param.length == 2) { parameters.put(URLDecoder.decode(param[0], "UTF-8"), URLDecoder.decode(param[1], "UTF-8")); } else if (param.length == 1) { parameters.put(URLDecoder.decode(param[0], "UTF-8"), null); } } } } catch (UnsupportedEncodingException e) { log.error("Failed to get request parameters from uri", e); } } return parameters; } private  URIUtils(); }
URIUtils { public static Map<String, String> getRequestParameters(String uriQuery) { Map<String, String> parameters = null; if (uriQuery != null && uriQuery.length() > 0) { try { String strippedQuery; int index = uriQuery.indexOf('?'); if (index != -1) { strippedQuery = uriQuery.substring(index + 1); } else { strippedQuery = uriQuery; } String[] items = strippedQuery.split("&"); if (items.length > 0) { parameters = new LinkedHashMap<>(); for (String item : items) { String[] param = item.split("="); if (param.length == 2) { parameters.put(URLDecoder.decode(param[0], "UTF-8"), URLDecoder.decode(param[1], "UTF-8")); } else if (param.length == 1) { parameters.put(URLDecoder.decode(param[0], "UTF-8"), null); } } } } catch (UnsupportedEncodingException e) { log.error("Failed to get request parameters from uri", e); } } return parameters; } private  URIUtils(); static String getURIQuery(Map<String, String> parameters); static String getURIPath(String uri); static Map<String, String> getRequestParameters(String uriQuery); static String addParametersToURIQuery(String uriString, Map<String, String> parameters); static String quoteURIPathComponent(String s, boolean quoteSlash); static String quoteURIPathComponent(String s, boolean quoteSlash, boolean quoteAt); static String quoteURIPathToken(String s); static String unquoteURIPathComponent(String s); }
URIUtils { public static Map<String, String> getRequestParameters(String uriQuery) { Map<String, String> parameters = null; if (uriQuery != null && uriQuery.length() > 0) { try { String strippedQuery; int index = uriQuery.indexOf('?'); if (index != -1) { strippedQuery = uriQuery.substring(index + 1); } else { strippedQuery = uriQuery; } String[] items = strippedQuery.split("&"); if (items.length > 0) { parameters = new LinkedHashMap<>(); for (String item : items) { String[] param = item.split("="); if (param.length == 2) { parameters.put(URLDecoder.decode(param[0], "UTF-8"), URLDecoder.decode(param[1], "UTF-8")); } else if (param.length == 1) { parameters.put(URLDecoder.decode(param[0], "UTF-8"), null); } } } } catch (UnsupportedEncodingException e) { log.error("Failed to get request parameters from uri", e); } } return parameters; } private  URIUtils(); static String getURIQuery(Map<String, String> parameters); static String getURIPath(String uri); static Map<String, String> getRequestParameters(String uriQuery); static String addParametersToURIQuery(String uriString, Map<String, String> parameters); static String quoteURIPathComponent(String s, boolean quoteSlash); static String quoteURIPathComponent(String s, boolean quoteSlash, boolean quoteAt); static String quoteURIPathToken(String s); static String unquoteURIPathComponent(String s);  }