1 package com.explosion.datastream.exql.impexp; 2 3 import java.io.Writer; 4 import java.util.Vector; 5 6 public class DelimitedExportFormatter implements TableExportFormatter { 7 8 private String delimiter = ","; 9 private boolean includeColumnNames = false; 10 11 public void write(Writer writer, Vector columnNames, Vector data) throws Exception{ 12 for (int i =0;i<columnNames.size();i++) 13 { 14 writer.write(data.get(i) + (i<columnNames.size()-1 ? delimiter : "")); 15 } 16 writer.write(System.getProperty("line.separator")); 17 } 18 19 public void writeHeader(Writer writer, Vector columnNames) throws Exception{ 20 if (includeColumnNames) 21 { 22 for (int i =0;i<columnNames.size();i++) 23 { 24 writer.write(columnNames.get(i) + (i<columnNames.size()-1 ? delimiter : "")); 25 } 26 writer.write(System.getProperty("line.separator")); 27 } 28 } 29 30 public void writeFooter(Writer writer, Vector columnNames) { 31 } 32 33 /*** 34 * @return Returns the delimiter. 35 */ 36 public String getDelimiter() { 37 return delimiter; 38 } 39 40 41 /*** 42 * @param delimiter The delimiter to set. 43 */ 44 public void setDelimiter(String delimiter) { 45 this.delimiter = delimiter; 46 } 47 48 /*** 49 * @return Returns the includeColumnNames. 50 */ 51 public boolean isIncludeColumnNames() { 52 return includeColumnNames; 53 } 54 55 56 /*** 57 * @param includeColumnNames The includeColumnNames to set. 58 */ 59 public void setIncludeColumnNames(boolean includeColumnNames) { 60 this.includeColumnNames = includeColumnNames; 61 } 62 63 64 65 66 } 67 68