Java Utililty Methods Collection Create

List of utility methods to do Collection Create

Description

The list of methods to do Collection Create are organized into topic(s).

Method

float[]createFloatArray(java.util.Collection collection)
create Float Array
final int N = collection.size();
float[] rv = new float[N];
int i = 0;
for (Float v : collection) {
    rv[i++] = v;
return rv;
CollectioncreateInstance(Class collectionType)
create Instance
return (Collection<E>) collectionType.newInstance();
int[]createIntArray(Collection collection)
create Int Array
int[] array = new int[collection.size()];
int i = 0;
for (Integer itereger : collection) {
    array[i++] = itereger;
return array;
StringcreateIntegerInClause(Collection p_integers)
create in clause of integers.
StringBuffer sf = new StringBuffer();
sf.append("(");
for (Iterator it = p_integers.iterator(); it.hasNext();) {
    Number id = (Number) it.next();
    sf.append(id.longValue());
    if (it.hasNext()) {
        sf.append(", ");
sf.append(")");
return sf.toString();
StringcreateNamedInsert(String tableName, Collection columnNames)
Create an insert SQL string for the table with the specified insert columns.
StringBuilder names = new StringBuilder();
StringBuilder values = new StringBuilder();
Iterator<String> it = columnNames.iterator();
while (it.hasNext()) {
    final String columnName = it.next();
    names.append(columnName);
    values.append(':').append(columnName);
    if (it.hasNext()) {
...
StringcreateNewValue(String value, Collection values)
create New Value
if (!values.contains(value)) {
    return value;
for (int i = 2;; i++) {
    String newValue = value + "_" + i;
    if (!values.contains(newValue)) {
        return newValue;
StringcreateNominalDescription(Collection values)
Create a nominal description from the possible values.
StringBuilder buffer = new StringBuilder();
int ind = 0;
for (String value : values) {
    buffer.append(value);
    if (++ind < values.size()) {
        buffer.append(',');
return buffer.toString();
StringcreateParameterizedWhereClause(Collection columns)
create Parameterized Where Clause
StringBuilder builder = new StringBuilder();
builder.append(" WHERE ");
Iterator<?> iter = columns.iterator();
while (iter.hasNext()) {
    Object column = iter.next();
    builder.append(column + " = ?");
    if (iter.hasNext()) {
        builder.append(" AND ");
...
TcreateStringCollection(Class clazz, String... elements)
create String Collection
T result = clazz.newInstance();
for (String element : elements) {
    result.add(element);
return result;
StringcreateStringFromCollection(Collection svcInterfaces)
create String From Collection
if (svcInterfaces == null) {
    return null;
final StringBuffer result = new StringBuffer();
for (final Iterator i = svcInterfaces.iterator(); i.hasNext();) {
    final String item = (String) i.next();
    result.append(item);
    if (i.hasNext()) {
...