Java Utililty Methods URL Build

List of utility methods to do URL Build

Description

The list of methods to do URL Build are organized into topic(s).

Method

StringbuildQuery(final Map query)
Turns the specified Map into an encoded & escaped query
if (query == null) {
    return "";
final StringBuilder builder = new StringBuilder();
for (final Map.Entry<String, Object> entry : query.entrySet()) {
    if (builder.length() > 0) {
        builder.append('&');
    try {
        builder.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
    } catch (final UnsupportedEncodingException e) {
    if (entry.getValue() != null) {
        builder.append('=');
        try {
            builder.append(URLEncoder.encode(entry.getValue().toString(), "UTF-8"));
        } catch (final UnsupportedEncodingException e) {
return builder.toString();
StringbuildQuery(final Map query)
build Query
if ((query == null) || query.isEmpty()) {
    return "";
return query.entrySet().stream()
        .map(entry -> createQueryElement(entry.getKey(),
                (entry.getValue() == null) ? null : entry.getValue().toString()))
        .reduce((s1, s2) -> s1 + "&" + s2).orElse("");
StringbuildQuery(Map paramMap)
build Query
StringBuilder localStringBuilder = new StringBuilder();
for (Map.Entry<String, Object> localEntry : paramMap.entrySet()) {
    if (localStringBuilder.length() > 0) {
        localStringBuilder.append('&');
    try {
        localStringBuilder.append(URLEncoder.encode((String) localEntry.getKey(), "UTF-8"));
    } catch (UnsupportedEncodingException localUnsupportedEncodingException1) {
...
StringbuildQuery(Map paramMap)
build valid http request querystrings from a hashmap that contains name value pairs Copied from Play Router class TODO: array support
StringBuilder queryString = new StringBuilder();
for (Map.Entry<String, Object> entry : paramMap.entrySet()) {
    String key = entry.getKey();
    Object value = entry.getValue();
    if (value != null) {
        if (List.class.isAssignableFrom(value.getClass())) {
            List<Object> vals = (List<Object>) value;
            for (Object e : vals) {
...
StringbuildQuery(Map query)
build Query
if (query == null) {
    return "";
} else {
    StringBuilder builder = new StringBuilder();
    Iterator<Entry<String, Object>> it = query.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, Object> entry = it.next();
        if (builder.length() > 0) {
...
StringbuildQuery(Map params)
build Query
StringBuilder sb = new StringBuilder();
boolean first = true;
for (Map.Entry<String, String> param : params.entrySet()) {
    if (!first) {
        sb.append("&");
    sb.append(URLEncoder.encode(param.getKey(), "UTF-8")).append("=")
            .append(URLEncoder.encode(param.getValue(), "UTF-8"));
...
StringbuildQueryString(Map parameters)
Builds a query string from the provided key-value-pairs.
StringBuffer queryString = new StringBuffer(20 * parameters.size());
for (Iterator it = parameters.entrySet().iterator(); it.hasNext();) {
    Map.Entry parameter = (Map.Entry) it.next();
    queryString.append(URLEncoder.encode((String) parameter.getKey(), "UTF-8"));
    queryString.append('=');
    queryString.append(URLEncoder.encode(String.valueOf(parameter.getValue()), "UTF-8"));
    if (it.hasNext())
        queryString.append('&');
...
StringbuildQueryString(Map params)
Creates a query string out of parameters map
StringBuilder sb = new StringBuilder();
Iterator<Map.Entry<String, Object>> entries = params.entrySet().iterator();
while (entries.hasNext()) {
    Map.Entry<String, Object> e = entries.next();
    if (sb.length() > 0) {
        sb.append('&');
    sb.append(URLEncoder.encode((String) e.getKey(), "UTF-8")).append('=')
...
StringbuildQueryString(Map queryParams)
Builds a URI query string from a map of keys and values.
StringBuffer buf = new StringBuffer();
boolean firstParam = true;
try {
    for (Map.Entry<String, Object> entry : queryParams.entrySet()) {
        if (entry.getValue() == null)
            continue;
        if (entry.getValue() instanceof List<?>) {
            List<?> values = (List<?>) entry.getValue();
...
StringbuildQueryString(Map params)
build Query String
String qs = "";
if (params == null)
    return qs;
int i = 0;
for (String param : params.keySet()) {
    qs += param + "=" + URLEncoder.encode(params.get(param), "UTF-8")
            + (i++ < (params.size() - 1) ? "&" : "");
return qs;