Class CSVExportFileWriter
java.lang.Object
com.broadleafcommerce.common.dataexport.service.CSVExportFileWriter
- All Implemented Interfaces:
ExportFileWriter<CSVExportFileWriteContext>
public class CSVExportFileWriter
extends Object
implements ExportFileWriter<CSVExportFileWriteContext>
An implementation of
ExportFileWriter that can write CSV files.- Author:
- Samarth Dhruva (samarthd)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether the writer can support writing the file for the given export.createExecutionContext(OutputStream outputStream) Creates a new instance of anExportFileWriteContextfor writing to the givenoutputStream.Returns the file extension that should be used for the export file that the writer will be writing to.writeHeaders(LinkedHashSet<String> headers, CSVExportFileWriteContext executionContext) Writes the given headers to the output file.Writes the given rows to the export file.
-
Constructor Details
-
CSVExportFileWriter
public CSVExportFileWriter()
-
-
Method Details
-
canHandle
Description copied from interface:ExportFileWriterReturns whether the writer can support writing the file for the given export. Generally this should be entirely based onExport.fileType.- Specified by:
canHandlein interfaceExportFileWriter<CSVExportFileWriteContext>- Parameters:
export- details about the export that will be processed- Returns:
- true if the file writer can support writing the file for the given export, false otherwise
-
getFileExtension
Description copied from interface:ExportFileWriterReturns the file extension that should be used for the export file that the writer will be writing to.- Specified by:
getFileExtensionin interfaceExportFileWriter<CSVExportFileWriteContext>- Returns:
- the file extension (including the ".") that should be used for the export file
-
createExecutionContext
Description copied from interface:ExportFileWriterCreates a new instance of anExportFileWriteContextfor writing to the givenoutputStream.- Specified by:
createExecutionContextin interfaceExportFileWriter<CSVExportFileWriteContext>- Parameters:
outputStream- the output stream that the writer should be writing to- Returns:
- a new instance of a file writing context that is bound to the given output stream
-
writeHeaders
public ExportFileWriteResponse writeHeaders(LinkedHashSet<String> headers, CSVExportFileWriteContext executionContext) Description copied from interface:ExportFileWriterWrites the given headers to the output file. TheExportFileWriteContext.outputStreamshould be left open for further writes.- Specified by:
writeHeadersin interfaceExportFileWriter<CSVExportFileWriteContext>- Parameters:
headers- the headers that need to be written to the export fileexecutionContext- state information for the particular export being written- Returns:
- a response describing whether the write operation succeeded or failed
-
writeRows
public ExportFileWriteResponse writeRows(List<Map<String, String>> rows, CSVExportFileWriteContext executionContext) Description copied from interface:ExportFileWriterWrites the given rows to the export file. TheExportFileWriteContext.outputStreamshould be left open for further writes.- Specified by:
writeRowsin interfaceExportFileWriter<CSVExportFileWriteContext>- Parameters:
rows- the rows that need to be written to the export fileexecutionContext- state information for the particular export being written- Returns:
- a response describing whether the write operation succeeded or failed
-