Java Comma Separated List getCommaSeparatedList(Collection stringValues)

Here you can find the source of getCommaSeparatedList(Collection stringValues)

Description

Utility method for creating display values

License

BSD License

Declaration

public static String getCommaSeparatedList(Collection<String> stringValues) 

Method Source Code

//package com.java2s;
/*L//ww  w  .ja  v a 2s. c o  m
 *  Copyright SAIC, Ellumen and RSNA (CTP)
 *
 *
 *  Distributed under the OSI-approved BSD 3-Clause License.
 *  See http://ncip.github.com/national-biomedical-image-archive/LICENSE.txt for details.
 */

import java.util.Collection;

import java.util.Iterator;

public class Main {
    /**
     * Utility method for creating display values
     *
     * @see gov.nih.nci.ncia.criteria.Criteria#getDisplayValue()
     */
    public static String getCommaSeparatedList(Collection<String> stringValues) {
        // Create a comma separated list
        StringBuilder values = new StringBuilder();

        if (stringValues.size() == 0) {
            return values.toString();
        }

        Iterator<String> i = stringValues.iterator();
        values.append((String) i.next());

        while (i.hasNext()) {
            values.append(", ");
            values.append((String) i.next());
        }

        return values.toString();
    }
}

Related

  1. getAsCommaDelimitedString(List coll)
  2. getCommaList(List V)
  3. getCommandLine(List command)
  4. getCommandLineOptionInt(List args, String param, int defaultValue)
  5. getCommandStr(List commandList)
  6. getCommaSeparatedList(List list)
  7. getCommaSeparatedList(List list)
  8. getCommaSeparatedListOfString( Collection list)
  9. getCommaSeparatedValue(List> enumList)