Example usage for org.apache.commons.collections CollectionUtils transformedCollection

List of usage examples for org.apache.commons.collections CollectionUtils transformedCollection

Introduction

In this page you can find the example usage for org.apache.commons.collections CollectionUtils transformedCollection.

Prototype

public static Collection transformedCollection(Collection collection, Transformer transformer) 

Source Link

Document

Returns a transformed bag backed by the given collection.

Usage

From source file:gov.nih.nci.caarray.util.owlparser.SqlOntologyOwlParser.java

@SuppressWarnings(UNCHECKED)
private void writeSqlLine(String toTable, String[] fromTables, String[] columns, String[] selectEntries,
        Map<String, String> whereEntries) throws ParseException {
    StringBuilder sqlLine = new StringBuilder("insert into ").append(toTable);
    sqlLine.append(" (").append(StringUtils.join(columns, ",")).append(")");
    sqlLine.append(" select ").append(StringUtils.join(selectEntries, ", "));
    sqlLine.append(" from ").append(StringUtils.join(fromTables, ", "));
    sqlLine.append(" where ");
    sqlLine.append(//ww  w .j a v a  2s. c o m
            StringUtils.join(CollectionUtils.transformedCollection(whereEntries.entrySet(), new Transformer() {
                public Object transform(Object o) {
                    Map.Entry<String, String> whereEntry = (Map.Entry<String, String>) o;
                    return new StringBuilder(whereEntry.getKey()).append(" = ").append(whereEntry.getValue())
                            .toString();
                }
            }), " and "));
    sqlLine.append(";\n");
    try {
        sqlFileWriter.write(sqlLine.toString());
    } catch (IOException e) {
        throw new ParseException(e);
    }
}