Java Collection to String toString(Collection softwareTags)

Here you can find the source of toString(Collection softwareTags)

Description

to String

License

Open Source License

Declaration

public static String toString(Collection softwareTags) 

Method Source Code


//package com.java2s;

import java.util.Collection;
import java.util.Iterator;

public class Main {
    private static final char QUOTE = '\"';
    private static final char SPACE = ' ';

    public static String toString(Collection softwareTags) {
        StringBuffer sb = new StringBuffer();
        for (Iterator i = softwareTags.iterator(); i.hasNext();) {
            Object softwareTag = i.next();
            String tagName = null;
            /*if (softwareTag instanceof SoftwareTag) {
               tagName = ((SoftwareTag) softwareTag).getTagName();
            } else {/*w ww  .  j  a v a  2  s  .com*/
               tagName = softwareTag.toString();
            }*/

            sb.append(SPACE);
            if (tagName.indexOf(SPACE) != -1) {
                sb.append(QUOTE).append(tagName).append(QUOTE);
            } else {
                sb.append(tagName);
            }
        }
        return sb.toString().trim();
    }
}

Related

  1. toString(Collection c)
  2. toString(Collection c, String start, String separator, String end)
  3. toString(Collection collection, String separator, int fixedLength)
  4. toString(Collection objects)
  5. toString(Collection setOfTests)
  6. toString(Collection collection)
  7. toString(Collection collection, String prefix, String suffix)
  8. toString(Collection c)
  9. toString(Collection c)