Java Collection Convert toSQLIn(Collection values)

Here you can find the source of toSQLIn(Collection values)

Description

to SQL In

License

Apache License

Declaration

public static String toSQLIn(Collection<String> values) 

Method Source Code


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

import java.util.Collection;

public class Main {

    public static String toSQLIn(Collection<String> values) {
        if (values == null || values.isEmpty())
            return null;

        String[] strvalues = new String[0];
        strvalues = (String[]) values.toArray(new String[values.size()]);

        return toSQLIn(strvalues);
    }/*  ww  w . j  ava2s  . c  o  m*/

    public static String toSQLIn(String[] values) {
        StringBuffer bf_sqlin = new StringBuffer();
        if (values == null || values.length == 0)
            return null;

        int len = values.length;
        for (int i = 0; i < len; i++) {
            bf_sqlin = bf_sqlin.append(", '").append(values[i]).append("' ");
        }
        String str_sqlin = bf_sqlin.substring(1).toString();

        return str_sqlin;
    }
}

Related

  1. toReadableString(Collection collection)
  2. toSeparatedString(Collection items, String separator)
  3. toSeperatedString(final Collection list)
  4. toSet(Collection c)
  5. toSingleton(Collection l)
  6. toStringBuilder( Collection collection, String delimiter)
  7. toStringColl(Collection set)
  8. toSV(Collection collection, String separator)
  9. toTestParameters(Collection rawParams)