Java URL Build buildUrl(String[] indexNames, String[] types, String operationOrId)

Here you can find the source of buildUrl(String[] indexNames, String[] types, String operationOrId)

Description

build Url

License

Apache License

Declaration

public static String buildUrl(String[] indexNames, String[] types, String operationOrId) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static final String[] EMPTY_ARRAY = new String[] {};

    public static String buildUrl(String[] indexNames, String[] types, String operationOrId) {
        StringBuilder urlBuilder = new StringBuilder();
        if (indexNames != null && indexNames.length > 0) {
            urlBuilder.append("/").append(String.join(",", indexNames));
        }/*www . j a v a 2 s .c  o  m*/
        if (types != null && types.length > 0) {
            urlBuilder.append("/").append(String.join(",", types));
        }
        if (operationOrId != null) {
            // final String[] splitBySlash = operationOrId.split("/");
            urlBuilder.append("/").append(operationOrId);
        }
        return urlBuilder.toString();
    }

    public static String buildUrl(String indexName, String type, String operationOrId) {
        String[] types = type != null ? new String[] { type } : EMPTY_ARRAY;
        String[] indexNames = indexName != null ? new String[] { indexName } : EMPTY_ARRAY;
        return buildUrl(indexNames, types, operationOrId);
    }

    public static String buildUrl(String indexName, String documentType) {
        return buildUrl(indexName, documentType, null);
    }
}

Related

  1. buildUrl(String host, String target)
  2. buildUrl(String protocol, String host, int port, String context)
  3. buildUrl(String scheme, String base, String path, String query)
  4. buildUrl(String scheme, String host, int port)
  5. buildUrl(String uri)
  6. buildUrlAsString(String scheme, String host, int port, String path)
  7. buildURLForParams(String... urlParams)
  8. buildURLForParamsWithPrefix(String prefix, String... urlParams)
  9. buildURLForPath(String[] _path)