Example usage for org.springframework.util StringUtils collectionToDelimitedString

List of usage examples for org.springframework.util StringUtils collectionToDelimitedString

Introduction

In this page you can find the example usage for org.springframework.util StringUtils collectionToDelimitedString.

Prototype

public static String collectionToDelimitedString(@Nullable Collection<?> coll, String delim) 

Source Link

Document

Convert a Collection into a delimited String (e.g.

Usage

From source file:Main.java

/**
 * Formats a set of string values into a format appropriate for sending as a single-valued form value.
 * //www  .  j a va  2  s .  c o  m
 * @param value The value of the parameter.
 * @return The value formatted for form submission etc, or null if the input is empty
 */
public static String formatParameterList(Collection<String> value) {
    return value == null ? null : StringUtils.collectionToDelimitedString(value, " ");
}

From source file:org.kaloz.datafeed.yahoo.integration.test.stub.YahooStub.java

public void setMockAnswer(List<String> messages) {
    this.messages = StringUtils.collectionToDelimitedString(messages, "\r\n");
}

From source file:org.kaloz.datafeed.yahoo.infrastructure.acl.InstrumentPriceLoadCommandMessageConverter.java

@Converter
public String toUrl(InstrumentPriceLoadCommandMessage instrumentPriceLoadCommandMessage) {
    if (instrumentPriceLoadCommandMessage.getShortNames() == null
            || instrumentPriceLoadCommandMessage.getShortNames().isEmpty()) {
        throw new RuntimeException("Empty list cannot be converted to a proper URL!");
    }// w  ww .  jav  a 2s.  co  m
    return String.format(yahooUrl,
            StringUtils.collectionToDelimitedString(instrumentPriceLoadCommandMessage.getShortNames(), "+"));
}

From source file:org.javelin.sws.ext.utils.NamespaceUtils.java

/**
 * Converts package name to URL for namespace according to JAXB/JAX-WS conventions with separate domain and path fragments
 * /*from  www  .j a v  a 2 s .co m*/
 * @param pkg
 * @param domainComponentCount number of package components to be converted into domain part of URL. If zero than entire package will be a domain
 * @return
 */
public static String packageNameToNamespace(Package pkg, int domainComponentCount) {
    Assert.notNull(pkg, "Package should not be null");
    Assert.isTrue(domainComponentCount != 1,
            "The domain part should not consist of one component. It may be zero or more than 1.");

    List<String> elements = new ArrayList<String>(Arrays.asList(pkg.getName().split("\\.")));
    if (domainComponentCount > 0) {
        List<String> domain = elements.subList(0, domainComponentCount);
        List<String> path = elements.subList(domainComponentCount, elements.size());
        Collections.reverse(domain);
        return "http://" + StringUtils.collectionToDelimitedString(domain, ".") + "/"
                + StringUtils.collectionToDelimitedString(path, "/");
    } else {
        Collections.reverse(elements);
        return "http://" + StringUtils.collectionToDelimitedString(elements, ".") + "/";
    }
}

From source file:org.cloudfoundry.maven.common.CommonUtils.java

/**
 * Convert a List of Strings to a comma delimited String.
 *
 * @param list/*from   w w  w  .ja va2 s  . c  o  m*/
 * @return Returns the List as a comma delimited String. Returns an empty
 *         String for a Null or empty list.
 */
public static String collectionToCommaDelimitedString(Collection<String> list) {
    return StringUtils.collectionToDelimitedString(list, ", ");
}

From source file:com.nebhale.buildmonitor.web.AbstractControllerTest.java

final String toJson(String... pairs) {
    StringBuilder sb = new StringBuilder("{ ");

    Set<String> entries = Arrays.stream(pairs).map(pair -> {
        String[] parts = StringUtils.split(pair, ":");
        return String.format("\"%s\" : \"%s\"", parts[0], parts[1]);
    }).collect(Collectors.toSet());

    sb.append(StringUtils.collectionToDelimitedString(entries, ", "));

    return sb.append(" }").toString();
}

From source file:org.cloudfoundry.android.cfdroid.targets.TargetsPreferences.java

@TargetApi(11)
private void safePutStringSet(String key, Set<String> values) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        sharedPreferences.edit().putStringSet(key, values).commit();
    } else {/*  w  ww  .j a v  a 2s  .  co m*/
        String big = StringUtils.collectionToDelimitedString(values, "||");
        sharedPreferences.edit().putString(key + "__", big).commit();
    }
}

From source file:org.carewebframework.vista.security.base.BaseSecurityService.java

/**
 * Initialize security domain list.//from ww w  . j  a  v a2  s.c om
 */
@Override
protected void initSecurityDomains() {
    log.trace("Retrieving Security Domains");
    List<String> results = brokerSession.callRPCList("RGNETBRP DIVGET", null);
    String preLoginMessage = StringUtils.collectionToDelimitedString(brokerSession.getPreLoginMessage(), "\n");

    for (String result : results) {
        String[] pcs = StrUtil.split(result, StrUtil.U, 4);

        if (!pcs[2].isEmpty()) {
            Organization organization = new Organization();
            organization.setId(pcs[0]);
            organization.setName(pcs[1]);
            Map<String, String> attributes = new HashMap<String, String>();
            attributes.put(Constants.PROP_LOGIN_INFO, preLoginMessage);
            registerSecurityDomain(new SecurityDomainProxy(organization, attributes));
        }
    }
}

From source file:no.dusken.momus.service.search.ArticleQueryBuilder.java

private void buildQuery() {
    List<String> conditions = new ArrayList<>();

    if (search.getFree() != null && search.getFree().length() > 0) {
        String[] words = search.getFree().split(" ");

        for (int i = 0; i < words.length; i++) {
            conditions.add("a.rawcontent like :free" + i);
            queryParams.put("free" + i, "%" + words[i].toLowerCase() + "%");
        }//w w  w. j  a v a2s  .  co m
    }
    if (search.getStatus() != null) {
        conditions.add("a.status.id = :statusid");
        queryParams.put("statusid", search.getStatus());
    }
    if (search.getPersons() != null && search.getPersons().size() > 0) {
        int personCount = 0;

        for (Long person : search.getPersons()) {
            conditions.add("( :personid" + personCount + " member of a.journalists or " + ":personid"
                    + personCount + " member of a.photographers )");
            queryParams.put("personid" + personCount++, person);
        }
    }
    if (search.getSection() != null) {
        conditions.add("a.section.id = :secid");
        // TODO fix to use section!!
        queryParams.put("secid", search.getSection());
    }
    if (search.getPublication() != null) {
        conditions.add("a.publication.id = :pubid");
        queryParams.put("pubid", search.getPublication());
    }

    conditions.add("a.archived = :arch");
    queryParams.put("arch", search.getArchived());

    String allConditions = StringUtils.collectionToDelimitedString(conditions, " AND ");

    if (allConditions.equals("")) {
        fullQuery = baseQuery;
    } else {
        fullQuery = baseQuery + " WHERE " + allConditions;
    }

    fullQuery += " " + baseOrder;

    logger.debug("Search query: {}", fullQuery);

}

From source file:com.flipkart.phantom.thrift.impl.HystrixThriftProxy.java

/**
 * Abstract method implementation/*from   ww w.j a  va 2s  . c  om*/
 * @see com.flipkart.phantom.task.spi.AbstractHandler#getDetails()
 */
public String getDetails() {
    String details = "Service Class: " + this.getThriftServiceClass() + "\n";
    details += "Endpoint: " + this.getThriftServer() + ":" + this.getThriftPort() + "\n";
    details += "Timeout: " + this.getThriftTimeoutMillis() + "ms\n";
    details += "Executor Timeout: " + this.getProxyExecutorTimeout() + "ms\n";
    details += "Methods: " + StringUtils.collectionToDelimitedString(processMap.keySet(), ", ") + "\n";
    return details;
}