1 /*
2 * SymmetricDS is an open source database synchronization solution.
3 *
4 * Copyright (C) Chris Henson <chenson42@users.sourceforge.net>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see
18 * <http://www.gnu.org/licenses/>.
19 */
20
21 package org.jumpmind.symmetric.extract.csv;
22
23 import java.io.BufferedWriter;
24 import java.io.IOException;
25
26 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28 import org.jumpmind.symmetric.common.csv.CsvConstants;
29
30 public class Util {
31
32 static final Log logger = LogFactory.getLog(Util.class);
33
34 public static final String DELIMITER = ", ";
35
36 public static void write(BufferedWriter writer, String... data) throws IOException {
37 StringBuilder buffer = new StringBuilder();
38 for (String string : data) {
39 buffer.append(string);
40 }
41
42 writer.write(buffer.toString());
43 if (logger.isDebugEnabled()) {
44 logger.debug("writing: " + buffer);
45 }
46 }
47
48 public static void writeSql(String sql, BufferedWriter writer) throws IOException {
49 Util.write(writer, CsvConstants.SQL, DELIMITER, sql);
50 writer.newLine();
51 }
52 }