@Test public void testDecodeQueryParam() { assertEquals(" ", UriComponent.decode("+", UriComponent.Type.QUERY_PARAM)); assertEquals("a b c ", UriComponent.decode("a+b+c+", UriComponent.Type.QUERY_PARAM)); assertEquals(" ", UriComponent.decode("%20", UriComponent.Type.QUERY_PARAM)); assertEquals("a b c ", UriComponent.decode("a%20b%20c%20", UriComponent.Type.QUERY_PARAM)); }
@SuppressWarnings("StatementWithEmptyBody") private static void decodeQueryParam(final MultivaluedMap<String, String> params, final String param, final boolean decodeNames, final boolean decodeValues) { try { final int equals = param.indexOf('='); if (equals > 0) { params.add((decodeNames) ? URLDecoder.decode(param.substring(0, equals), "UTF-8") : param.substring(0, equals), (decodeValues) ? URLDecoder.decode(param.substring(equals + 1), "UTF-8") : param.substring(equals + 1)); } else if (equals == 0) { } else if (param.length() > 0) { params.add((decodeNames) ? URLDecoder.decode(param, "UTF-8") : param, ""); } } catch (final UnsupportedEncodingException ex) { throw new IllegalArgumentException(ex); } }
UriComponent { @SuppressWarnings("StatementWithEmptyBody") private static void decodeQueryParam(final MultivaluedMap<String, String> params, final String param, final boolean decodeNames, final boolean decodeValues) { try { final int equals = param.indexOf('='); if (equals > 0) { params.add((decodeNames) ? URLDecoder.decode(param.substring(0, equals), "UTF-8") : param.substring(0, equals), (decodeValues) ? URLDecoder.decode(param.substring(equals + 1), "UTF-8") : param.substring(equals + 1)); } else if (equals == 0) { } else if (param.length() > 0) { params.add((decodeNames) ? URLDecoder.decode(param, "UTF-8") : param, ""); } } catch (final UnsupportedEncodingException ex) { throw new IllegalArgumentException(ex); } } }
UriComponent { @SuppressWarnings("StatementWithEmptyBody") private static void decodeQueryParam(final MultivaluedMap<String, String> params, final String param, final boolean decodeNames, final boolean decodeValues) { try { final int equals = param.indexOf('='); if (equals > 0) { params.add((decodeNames) ? URLDecoder.decode(param.substring(0, equals), "UTF-8") : param.substring(0, equals), (decodeValues) ? URLDecoder.decode(param.substring(equals + 1), "UTF-8") : param.substring(equals + 1)); } else if (equals == 0) { } else if (param.length() > 0) { params.add((decodeNames) ? URLDecoder.decode(param, "UTF-8") : param, ""); } } catch (final UnsupportedEncodingException ex) { throw new IllegalArgumentException(ex); } } private  UriComponent(); }
UriComponent { @SuppressWarnings("StatementWithEmptyBody") private static void decodeQueryParam(final MultivaluedMap<String, String> params, final String param, final boolean decodeNames, final boolean decodeValues) { try { final int equals = param.indexOf('='); if (equals > 0) { params.add((decodeNames) ? URLDecoder.decode(param.substring(0, equals), "UTF-8") : param.substring(0, equals), (decodeValues) ? URLDecoder.decode(param.substring(equals + 1), "UTF-8") : param.substring(equals + 1)); } else if (equals == 0) { } else if (param.length() > 0) { params.add((decodeNames) ? URLDecoder.decode(param, "UTF-8") : param, ""); } } catch (final UnsupportedEncodingException ex) { throw new IllegalArgumentException(ex); } } private  UriComponent(); static void validate(final String s, final Type t); static void validate(final String s, final Type t, final boolean template); static boolean valid(final String s, final Type t); static boolean valid(final String s, final Type t, final boolean template); static String contextualEncode(final String s, final Type t); static String contextualEncode(final String s, final Type t, final boolean template); static String encode(final String s, final Type t); static String encode(final String s, final Type t, final boolean template); static String encodeTemplateNames(String s); static String decode(final String s, final Type t); static MultivaluedMap<String, String> decodeQuery(final URI u, final boolean decode); static MultivaluedMap<String, String> decodeQuery(final String q, final boolean decode); static MultivaluedMap<String, String> decodeQuery(final String q, final boolean decodeNames,
                                                             final boolean decodeValues); static List<PathSegment> decodePath(final URI u, final boolean decode); static List<PathSegment> decodePath(final String path, final boolean decode); static void decodePathSegment(final List<PathSegment> segments, final String segment, final boolean decode); static MultivaluedMap<String, String> decodeMatrix(final String pathSegment, final boolean decode); static boolean isHexCharacter(final char c); static String fullRelativeUri(final URI uri); }
UriComponent { @SuppressWarnings("StatementWithEmptyBody") private static void decodeQueryParam(final MultivaluedMap<String, String> params, final String param, final boolean decodeNames, final boolean decodeValues) { try { final int equals = param.indexOf('='); if (equals > 0) { params.add((decodeNames) ? URLDecoder.decode(param.substring(0, equals), "UTF-8") : param.substring(0, equals), (decodeValues) ? URLDecoder.decode(param.substring(equals + 1), "UTF-8") : param.substring(equals + 1)); } else if (equals == 0) { } else if (param.length() > 0) { params.add((decodeNames) ? URLDecoder.decode(param, "UTF-8") : param, ""); } } catch (final UnsupportedEncodingException ex) { throw new IllegalArgumentException(ex); } } private  UriComponent(); static void validate(final String s, final Type t); static void validate(final String s, final Type t, final boolean template); static boolean valid(final String s, final Type t); static boolean valid(final String s, final Type t, final boolean template); static String contextualEncode(final String s, final Type t); static String contextualEncode(final String s, final Type t, final boolean template); static String encode(final String s, final Type t); static String encode(final String s, final Type t, final boolean template); static String encodeTemplateNames(String s); static String decode(final String s, final Type t); static MultivaluedMap<String, String> decodeQuery(final URI u, final boolean decode); static MultivaluedMap<String, String> decodeQuery(final String q, final boolean decode); static MultivaluedMap<String, String> decodeQuery(final String q, final boolean decodeNames,
                                                             final boolean decodeValues); static List<PathSegment> decodePath(final URI u, final boolean decode); static List<PathSegment> decodePath(final String path, final boolean decode); static void decodePathSegment(final List<PathSegment> segments, final String segment, final boolean decode); static MultivaluedMap<String, String> decodeMatrix(final String pathSegment, final boolean decode); static boolean isHexCharacter(final char c); static String fullRelativeUri(final URI uri);  }