Interface ExportFileWriter<C extends ExportFileWriteContext>
-
- All Known Implementing Classes:
CSVExportFileWriter
public interface ExportFileWriter<C extends ExportFileWriteContext>Responsible for writing the headers and rows of an export to a file. Different file formats and types will require different implementations of this.Generally speaking, there should be one
ExportFileWriterfor eachExport.fileTypethat needs to be supported.The
ExportManagerwill use only the firstExportFileWriterfor whichcanHandle(Export)returns true.- Author:
- Samarth Dhruva (samarthd)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancanHandle(Export export)Returns whether the writer can support writing the file for the given export.CcreateExecutionContext(OutputStream outputStream)Creates a new instance of anExportFileWriteContextfor writing to the givenoutputStream.StringgetFileExtension()Returns the file extension that should be used for the export file that the writer will be writing to.ExportFileWriteResponsewriteHeaders(LinkedHashSet<String> headers, C executionContext)Writes the given headers to the output file.ExportFileWriteResponsewriteRows(List<Map<String,String>> rows, C executionContext)Writes the given rows to the export file.
-
-
-
Method Detail
-
canHandle
boolean canHandle(Export export)
Returns whether the writer can support writing the file for the given export. Generally this should be entirely based onExport.fileType.- 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
String getFileExtension()
Returns the file extension that should be used for the export file that the writer will be writing to.- Returns:
- the file extension (including the ".") that should be used for the export file
-
createExecutionContext
C createExecutionContext(OutputStream outputStream)
Creates a new instance of anExportFileWriteContextfor writing to the givenoutputStream.- 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
ExportFileWriteResponse writeHeaders(LinkedHashSet<String> headers, C executionContext)
Writes the given headers to the output file. TheExportFileWriteContext.outputStreamshould be left open for further writes.- 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
ExportFileWriteResponse writeRows(List<Map<String,String>> rows, C executionContext)
Writes the given rows to the export file. TheExportFileWriteContext.outputStreamshould be left open for further writes.- 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
-
-