List of usage examples for org.apache.commons.collections CollectionUtils transformedCollection
public static Collection transformedCollection(Collection collection, Transformer transformer)
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); } }