@Test public void parsesQueryString_EVERREST_58() { String str = "q1=bar&&q2=foo&q2=test"; MultivaluedMapImpl expected = new MultivaluedMapImpl(); expected.add("q1", "bar"); expected.addAll("q2", "foo", "test"); MultivaluedMap<String, String> result = parseQueryString(str, false); assertEquals(expected, result); result = parseQueryString(str, true); assertEquals(expected, result); }
public static MultivaluedMap<String, String> parseQueryString(String rawQuery, boolean decode) { MultivaluedMap<String, String> result = new MultivaluedMapImpl(); if (!(rawQuery == null || rawQuery.isEmpty())) { int p = 0; int n = 0; while (n < rawQuery.length()) { n = rawQuery.indexOf('&', p); if (n < 0) { n = rawQuery.length(); } String pair = rawQuery.substring(p, n); if (!pair.isEmpty()) { String name; String value; int eq = pair.indexOf('='); if (eq < 0) { name = pair; value = ""; } else { name = pair.substring(0, eq); value = pair.substring(eq + 1); } result.add(decode ? decode(name, QUERY) : name, decode ? decode(value, QUERY) : value); } p = n + 1; } } return result; }
UriComponent { public static MultivaluedMap<String, String> parseQueryString(String rawQuery, boolean decode) { MultivaluedMap<String, String> result = new MultivaluedMapImpl(); if (!(rawQuery == null || rawQuery.isEmpty())) { int p = 0; int n = 0; while (n < rawQuery.length()) { n = rawQuery.indexOf('&', p); if (n < 0) { n = rawQuery.length(); } String pair = rawQuery.substring(p, n); if (!pair.isEmpty()) { String name; String value; int eq = pair.indexOf('='); if (eq < 0) { name = pair; value = ""; } else { name = pair.substring(0, eq); value = pair.substring(eq + 1); } result.add(decode ? decode(name, QUERY) : name, decode ? decode(value, QUERY) : value); } p = n + 1; } } return result; } }
UriComponent { public static MultivaluedMap<String, String> parseQueryString(String rawQuery, boolean decode) { MultivaluedMap<String, String> result = new MultivaluedMapImpl(); if (!(rawQuery == null || rawQuery.isEmpty())) { int p = 0; int n = 0; while (n < rawQuery.length()) { n = rawQuery.indexOf('&', p); if (n < 0) { n = rawQuery.length(); } String pair = rawQuery.substring(p, n); if (!pair.isEmpty()) { String name; String value; int eq = pair.indexOf('='); if (eq < 0) { name = pair; value = ""; } else { name = pair.substring(0, eq); value = pair.substring(eq + 1); } result.add(decode ? decode(name, QUERY) : name, decode ? decode(value, QUERY) : value); } p = n + 1; } } return result; } private  UriComponent(); }
UriComponent { public static MultivaluedMap<String, String> parseQueryString(String rawQuery, boolean decode) { MultivaluedMap<String, String> result = new MultivaluedMapImpl(); if (!(rawQuery == null || rawQuery.isEmpty())) { int p = 0; int n = 0; while (n < rawQuery.length()) { n = rawQuery.indexOf('&', p); if (n < 0) { n = rawQuery.length(); } String pair = rawQuery.substring(p, n); if (!pair.isEmpty()) { String name; String value; int eq = pair.indexOf('='); if (eq < 0) { name = pair; value = ""; } else { name = pair.substring(0, eq); value = pair.substring(eq + 1); } result.add(decode ? decode(name, QUERY) : name, decode ? decode(value, QUERY) : value); } p = n + 1; } } return result; } private  UriComponent(); static URI normalize(URI uri); static String encode(String str, int component, boolean containsUriParams); static String validateUriComponent(String str, int component, boolean containsUriParams); static boolean isUriComponentContainsValidCharacters(int component, String str); static String recognizeEncode(String str, int component, boolean containsUriParams); static String decode(String str, int component); static boolean checkHexCharacters(String s, int p); static List<PathSegment> parsePathSegments(String path, boolean decode); static MultivaluedMap<String, String> parseQueryString(String rawQuery, boolean decode); static URI resolve(URI baseUri, URI resolvingUri); }
UriComponent { public static MultivaluedMap<String, String> parseQueryString(String rawQuery, boolean decode) { MultivaluedMap<String, String> result = new MultivaluedMapImpl(); if (!(rawQuery == null || rawQuery.isEmpty())) { int p = 0; int n = 0; while (n < rawQuery.length()) { n = rawQuery.indexOf('&', p); if (n < 0) { n = rawQuery.length(); } String pair = rawQuery.substring(p, n); if (!pair.isEmpty()) { String name; String value; int eq = pair.indexOf('='); if (eq < 0) { name = pair; value = ""; } else { name = pair.substring(0, eq); value = pair.substring(eq + 1); } result.add(decode ? decode(name, QUERY) : name, decode ? decode(value, QUERY) : value); } p = n + 1; } } return result; } private  UriComponent(); static URI normalize(URI uri); static String encode(String str, int component, boolean containsUriParams); static String validateUriComponent(String str, int component, boolean containsUriParams); static boolean isUriComponentContainsValidCharacters(int component, String str); static String recognizeEncode(String str, int component, boolean containsUriParams); static String decode(String str, int component); static boolean checkHexCharacters(String s, int p); static List<PathSegment> parsePathSegments(String path, boolean decode); static MultivaluedMap<String, String> parseQueryString(String rawQuery, boolean decode); static URI resolve(URI baseUri, URI resolvingUri); static final int SCHEME; static final int USER_INFO; static final int HOST; static final int PORT; static final int PATH_SEGMENT; static final int PATH; static final int QUERY; static final int FRAGMENT; static final int SSP; static final int MATRIX_PARAM; static final int QUERY_STRING; static final String PERCENT; }