@Test public void testParsePrefixedParamsMap() throws Exception { HttpServletRequest req = mock(HttpServletRequest.class); Map<String, String> input = new HashMap<String, String>(); input.put(PREFIX + "fi", "test suomi"); input.put(PREFIX + "en", "test english"); for(String key : input.keySet()) { doReturn(input.get(key)).when(req).getParameter(key); } doReturn(Collections.enumeration(input.keySet())).when(req).getParameterNames(); final Map<String, String> map = RequestHelper.parsePrefixedParamsMap (req, PREFIX); assertEquals("Should have two entries", 2, map.size()); assertEquals("Should parse finnish", "test suomi", map.get("fi")); assertEquals("Should parse english", "test english", map.get("en")); }
public static Map<String, String> parsePrefixedParamsMap(final HttpServletRequest request, final String paramNamePrefix) { final Map<String, String> result = new HashMap<String, String>(); final int prefixLength = paramNamePrefix.length(); final Enumeration<String> paramNames = request.getParameterNames(); while (paramNames.hasMoreElements()) { final String nextName = paramNames.nextElement(); if (nextName.indexOf(paramNamePrefix) == 0) { result.put(nextName.substring(prefixLength), request.getParameter(nextName)); } } return result; }
RequestHelper { public static Map<String, String> parsePrefixedParamsMap(final HttpServletRequest request, final String paramNamePrefix) { final Map<String, String> result = new HashMap<String, String>(); final int prefixLength = paramNamePrefix.length(); final Enumeration<String> paramNames = request.getParameterNames(); while (paramNames.hasMoreElements()) { final String nextName = paramNames.nextElement(); if (nextName.indexOf(paramNamePrefix) == 0) { result.put(nextName.substring(prefixLength), request.getParameter(nextName)); } } return result; } }
RequestHelper { public static Map<String, String> parsePrefixedParamsMap(final HttpServletRequest request, final String paramNamePrefix) { final Map<String, String> result = new HashMap<String, String>(); final int prefixLength = paramNamePrefix.length(); final Enumeration<String> paramNames = request.getParameterNames(); while (paramNames.hasMoreElements()) { final String nextName = paramNames.nextElement(); if (nextName.indexOf(paramNamePrefix) == 0) { result.put(nextName.substring(prefixLength), request.getParameter(nextName)); } } return result; }  }
RequestHelper { public static Map<String, String> parsePrefixedParamsMap(final HttpServletRequest request, final String paramNamePrefix) { final Map<String, String> result = new HashMap<String, String>(); final int prefixLength = paramNamePrefix.length(); final Enumeration<String> paramNames = request.getParameterNames(); while (paramNames.hasMoreElements()) { final String nextName = paramNames.nextElement(); if (nextName.indexOf(paramNamePrefix) == 0) { result.put(nextName.substring(prefixLength), request.getParameter(nextName)); } } return result; }  static final String cleanString(final String str); static final String cleanHTMLString(final String str, final String[] tags,
            HashMap<String, String[]> attributes, HashMap<String[],String[]> protocols); static final String cleanHTMLString(final String str); static final String getString(final String str, final String defaultValue); static final String getDomainFromReferer(final String referrer); static Map<String, String> parsePrefixedParamsMap(final HttpServletRequest request, final String paramNamePrefix); }
RequestHelper { public static Map<String, String> parsePrefixedParamsMap(final HttpServletRequest request, final String paramNamePrefix) { final Map<String, String> result = new HashMap<String, String>(); final int prefixLength = paramNamePrefix.length(); final Enumeration<String> paramNames = request.getParameterNames(); while (paramNames.hasMoreElements()) { final String nextName = paramNames.nextElement(); if (nextName.indexOf(paramNamePrefix) == 0) { result.put(nextName.substring(prefixLength), request.getParameter(nextName)); } } return result; }  static final String cleanString(final String str); static final String cleanHTMLString(final String str, final String[] tags,
            HashMap<String, String[]> attributes, HashMap<String[],String[]> protocols); static final String cleanHTMLString(final String str); static final String getString(final String str, final String defaultValue); static final String getDomainFromReferer(final String referrer); static Map<String, String> parsePrefixedParamsMap(final HttpServletRequest request, final String paramNamePrefix);  }