コード例 #1
0
 private void writeHeaderRow() throws DataAccessObjectInitializationException {
   CSVColumnVisitor visitor = new CSVColumnVisitor(fileOut);
   try {
     visitHeaderColumns(this.columnNames, visitor);
     fileOut.newLine();
     visitor.newRow();
   } catch (IOException e) {
     String errMsg = Messages.getString("CSVWriter.errorWriting");
     logger.error(errMsg, e); // $NON-NLS-1$
     throw new DataAccessObjectInitializationException(errMsg, e);
   }
 }
コード例 #2
0
 /*
  * (non-Javadoc)
  * @see com.salesforce.dataloader.dao.csv.Writer#writeRow(java.util.Map)
  */
 public boolean writeRow(Map<String, Object> columnValues) throws DataAccessObjectException {
   CSVColumnVisitor visitor = new CSVColumnVisitor(fileOut);
   try {
     visitColumns(columnNames, columnValues, visitor);
     fileOut.newLine();
     visitor.newRow();
     currentRowNumber++;
     return true; // success unless there's an exception
   } catch (IOException e) {
     logger.error(Messages.getString("CSVWriter.errorWriting"), e); // $NON-NLS-1$
     throw new DataAccessObjectException(
         Messages.getString("CSVWriter.errorWriting"), e); // $NON-NLS-1$
   }
 }
コード例 #3
0
 private static void visitColumns(
     List<String> columnNames, Map<String, Object> columnValues, CSVColumnVisitor visitor)
     throws IOException {
   for (String colName : columnNames) {
     Object colVal = columnValues.get(colName);
     visitor.visit(colVal != null ? colVal.toString() : "");
   }
 }
コード例 #4
0
 private void visitHeaderColumns(List<String> columnNames, CSVColumnVisitor visitor)
     throws IOException {
   for (String colName : columnNames) {
     String outColName;
     if (colName != null) {
       if (this.capitalizedHeadings) {
         outColName = colName.toUpperCase();
       } else {
         outColName = colName;
       }
     } else {
       outColName = "";
     }
     visitor.visit(outColName);
   }
 }