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 ExportFileWriter
for each Export.fileType
that needs to be supported.
The ExportManager
will use only the first ExportFileWriter
for which
canHandle(Export)
returns true.
- Author:
- Samarth Dhruva (samarthd)
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether the writer can support writing the file for the given export.createExecutionContext
(OutputStream outputStream) Creates a new instance of anExportFileWriteContext
for 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, C executionContext) Writes the given headers to the output file.Writes the given rows to the export file.
-
Method Details
-
canHandle
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
Creates a new instance of anExportFileWriteContext
for 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
Writes the given headers to the output file. TheExportFileWriteContext.outputStream
should 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
Writes the given rows to the export file. TheExportFileWriteContext.outputStream
should 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
-