@Test public void testExtractQueryParameters() throws Exception { Map<String, String> result = RestUtil.extractQueryParameters("some=value"); Assert.assertEquals("value", result.get("some")); result = RestUtil.extractQueryParameters("some=value&another=v"); Assert.assertEquals("value", result.get("some")); Assert.assertEquals("v", result.get("another")); result = RestUtil.extractQueryParameters(""); Assert.assertTrue(result.isEmpty()); }
public static Map<String, String> extractQueryParameters(final String queryString) { Map<String, String> queryParametersMap = new HashMap<String, String>(); if (queryString != null && queryString.length() > 0) { List<String> queryParameters = Arrays.asList(queryString.split("\\&")); for (String param : queryParameters) { String decodedParam = Decoder.decode(param); int indexOfEqualSign = decodedParam.indexOf("="); if (indexOfEqualSign < 0) { queryParametersMap.put(decodedParam, ""); } else { queryParametersMap.put(decodedParam.substring(0, indexOfEqualSign), decodedParam .substring(indexOfEqualSign + 1)); } } } return queryParametersMap; }
RestUtil { public static Map<String, String> extractQueryParameters(final String queryString) { Map<String, String> queryParametersMap = new HashMap<String, String>(); if (queryString != null && queryString.length() > 0) { List<String> queryParameters = Arrays.asList(queryString.split("\\&")); for (String param : queryParameters) { String decodedParam = Decoder.decode(param); int indexOfEqualSign = decodedParam.indexOf("="); if (indexOfEqualSign < 0) { queryParametersMap.put(decodedParam, ""); } else { queryParametersMap.put(decodedParam.substring(0, indexOfEqualSign), decodedParam .substring(indexOfEqualSign + 1)); } } } return queryParametersMap; } }
RestUtil { public static Map<String, String> extractQueryParameters(final String queryString) { Map<String, String> queryParametersMap = new HashMap<String, String>(); if (queryString != null && queryString.length() > 0) { List<String> queryParameters = Arrays.asList(queryString.split("\\&")); for (String param : queryParameters) { String decodedParam = Decoder.decode(param); int indexOfEqualSign = decodedParam.indexOf("="); if (indexOfEqualSign < 0) { queryParametersMap.put(decodedParam, ""); } else { queryParametersMap.put(decodedParam.substring(0, indexOfEqualSign), decodedParam .substring(indexOfEqualSign + 1)); } } } return queryParametersMap; }  }
RestUtil { public static Map<String, String> extractQueryParameters(final String queryString) { Map<String, String> queryParametersMap = new HashMap<String, String>(); if (queryString != null && queryString.length() > 0) { List<String> queryParameters = Arrays.asList(queryString.split("\\&")); for (String param : queryParameters) { String decodedParam = Decoder.decode(param); int indexOfEqualSign = decodedParam.indexOf("="); if (indexOfEqualSign < 0) { queryParametersMap.put(decodedParam, ""); } else { queryParametersMap.put(decodedParam.substring(0, indexOfEqualSign), decodedParam .substring(indexOfEqualSign + 1)); } } } return queryParametersMap; }  static ContentType extractRequestContentType(final String contentType); static Map<String, String> extractQueryParameters(final String queryString); static Map<String, List<String>> extractAllQueryParameters(final String queryString, String formEncoding); static List<Locale> extractAcceptableLanguage(final String acceptableLanguageHeader); static List<String> extractAcceptHeaders(final String acceptHeader); @SuppressWarnings("unchecked") static Map<String, List<String>> extractHeaders(final HttpServletRequest req); static PathInfo buildODataPathInfo(final HttpServletRequest req, final int pathSplit); }
RestUtil { public static Map<String, String> extractQueryParameters(final String queryString) { Map<String, String> queryParametersMap = new HashMap<String, String>(); if (queryString != null && queryString.length() > 0) { List<String> queryParameters = Arrays.asList(queryString.split("\\&")); for (String param : queryParameters) { String decodedParam = Decoder.decode(param); int indexOfEqualSign = decodedParam.indexOf("="); if (indexOfEqualSign < 0) { queryParametersMap.put(decodedParam, ""); } else { queryParametersMap.put(decodedParam.substring(0, indexOfEqualSign), decodedParam .substring(indexOfEqualSign + 1)); } } } return queryParametersMap; }  static ContentType extractRequestContentType(final String contentType); static Map<String, String> extractQueryParameters(final String queryString); static Map<String, List<String>> extractAllQueryParameters(final String queryString, String formEncoding); static List<Locale> extractAcceptableLanguage(final String acceptableLanguageHeader); static List<String> extractAcceptHeaders(final String acceptHeader); @SuppressWarnings("unchecked") static Map<String, List<String>> extractHeaders(final HttpServletRequest req); static PathInfo buildODataPathInfo(final HttpServletRequest req, final int pathSplit);  }