StringUtils { public static String addQueryParameters(String uri, Object... parameters) { if (uri == null) { return null; } StringBuilder query = new StringBuilder(); int questionAt = uri.indexOf('?'); if (questionAt > -1) { String queryString = uri.substring(questionAt + 1); int beginAt = 0; while (true) { int ampIndex = queryString.indexOf('&', beginAt); String param = queryString.substring(beginAt, ampIndex > -1 ? ampIndex : queryString.length()); if (!param.isEmpty() || ampIndex > -1) { query.append('&'); int equalsIndex = param.indexOf('='); if (equalsIndex > -1) { query.append(encodeUri(decodeUri(param.substring(0, equalsIndex)))); query.append('='); query.append(encodeUri(decodeUri(param.substring(equalsIndex + 1)))); } else { query.append(encodeUri(decodeUri(param))); } } if (ampIndex > -1) { beginAt = ampIndex + 1; } else { break; } } uri = uri.substring(0, questionAt); } int parametersLength = parameters != null ? parameters.length : 0; for (int i = 0; i < parametersLength; i += 2) { String name = parameters[i].toString(); String prefix = "&" + name + "="; int prefixLength = prefix.length(); int beginAt = 0; int endAt; while (true) { beginAt = query.indexOf(prefix, beginAt); if (beginAt < 0) { break; } endAt = query.indexOf("&", beginAt + prefixLength); if (endAt > -1) { query.delete(beginAt, endAt); } else { query.delete(beginAt, query.length()); break; } } if (i + 1 < parametersLength) { Object value = parameters[i + 1]; if (value != null) { for (Object item : ObjectUtils.to(Iterable.class, value)) { if (item != null) { query.append('&'); query.append(encodeUri(name)); query.append('='); query.append(encodeUri(item instanceof Enum ? ((Enum<?>) item).name() : item.toString())); } } } } } if (query.length() <= 1) { return uri; } else { query.delete(0, 1); query.insert(0, "?"); query.insert(0, uri); return query.toString(); } }  @Deprecated static T fromString(Class<T> returnType, String... strings); static String toDelimited(String string, String delimiter); static String toHyphenated(String string); static String toUnderscored(String string); static String toPascalCase(String string); static String toCamelCase(String string); static String toLabel(String string); static String toNormalized(CharSequence string); static String[] fromCsv(String string); static String toCsv(String... strings); static String escapeHtmlAndBreak(String string, int maxWordLength); static String escapeHtmlAndBreak(String string); static String hex(byte[] bytes); static byte[] hash(String algorithm, String string); static byte[] md5(String string); static byte[] sha1(String string); static byte[] sha512(String string); static byte[] hmac(String algorithm, String key, String string); static byte[] hmacSha1(String key, String string); static String encodeUri(String string); static String decodeUri(String string); static String addQueryParameters(String uri, Object... parameters); static String getQueryParameterValue(String uri, String name); static List<String> getQueryParameterValues(String uri, String name); static Map<String, List<String>> getQueryParameterMap(String url); @Deprecated static String transformUri(String uri, Object... parameters); @Deprecated static String getParameter(String uri, String name); @Deprecated static String[] getParameterValues(String uri, String name); static Pattern getPattern(String pattern); static Matcher getMatcher(CharSequence string, String pattern); static MatchResult getMatcherResult(CharSequence string, String pattern); static boolean matches(CharSequence string, String pattern); static boolean matchAll(CharSequence string, String... patterns); static boolean matchAny(CharSequence string, String... patterns); static int matchCount(CharSequence string, String... patterns); static String replaceAll(CharSequence string, String pattern, String replacement); static String replaceAll(CharSequence string, String pattern, String replacement, String... more); static String removeAll(CharSequence string, CharSequence pattern); static String[] split(CharSequence string, String pattern, int limit); static String[] split(CharSequence string, String pattern); static String escapeCsv(String string); static String escapeHtml(String string); static String escapeJava(String string); static String escapeJavaScript(String string); static String escapeQuotes(String string); static String escapeSql(String string); static String escapeXml(String string); static String unescapeCsv(String string); static String unescapeHtml(String string); static String unescapeJava(String string); static String unescapeJavaScript(String string); static String unescapeXml(String string); static String join(List<String> strings, String delimiter); static String join(String[] strings, String delimiter); static boolean isEmpty(String string); static boolean isBlank(String string); static boolean equals(String str1, String str2); static boolean equalsIgnoreCase(String str1, String str2); static String stripHtml(CharSequence sequence); static String ensureStart(String string, String delimiter); static String ensureEnd(String string, String delimiter); static String ensureSurrounding(String string, String delimiter); static String removeStart(String string, String delimiter); static String removeEnd(String string, String delimiter); static String removeSurrounding(String string, String delimiter); static String getPathInfo(String path, String servletPath); static String toLowerCaseAscii(String string); static String trimAndCollapseWhitespaces(String string); static String getFileName(String filePath); @Deprecated
    static final Charset US_ASCII; @Deprecated
    static final Charset ISO_8859_1; @Deprecated
    static final Charset UTF_8; @Deprecated
    static final Charset UTF_16BE; @Deprecated
    static final Charset UTF_16LE; @Deprecated
    static final Charset UTF_16; }
@Test public void addQueryParameters_simple() { assertEquals("http: }
@Test public void addQueryParameters_append() { assertEquals("http: }
@Test public void addQueryParameters_multiple() { assertEquals("http: }
@Test public void addQueryParameters_escape() { assertEquals("http: }
@Test public void addQueryParameters_url() { assertEquals("http: }
@Test public void addQueryParameters_null() { assertEquals(null, StringUtils.addQueryParameters(null, "b", "1")); }
@Test public void addQueryParameters_noparams() { assertEquals("http: }
@Test (expected=NullPointerException.class) public void addQueryParameters_nullparamname() { StringUtils.addQueryParameters("http: }
@Test public void addQueryParameters_emptyparamname() { StringUtils.addQueryParameters("http: }
@Test public void addQueryParameters_nullparamvalue() { assertEquals("http: }
@Test public void addQueryParameters_emptyparamvalue() { assertEquals("http: assertEquals("http: }