@NotThreadSafe public class ExporterCSV extends Object implements IExporterFile
IExporterFile for CSV files.| Constructor and Description |
|---|
ExporterCSV() |
ExporterCSV(Charset aCharset) |
| Modifier and Type | Method and Description |
|---|---|
protected com.helger.commons.csv.CSVWriter |
createCSVWriter(OutputStream aOS)
Create a new CSV writer.
|
com.helger.commons.state.ESuccess |
exportRecords(IExportRecordProvider aProvider,
OutputStream aOS)
Export all provided records to an output stream.
|
Charset |
getCharset() |
char |
getEscapeChar() |
EExchangeFileType |
getFileType() |
String |
getLineEnd() |
char |
getQuoteChar() |
char |
getSeparatorChar() |
com.helger.commons.charset.EUnicodeBOM |
getUnicodeBOM() |
boolean |
isAvoidFinalLineEnd() |
boolean |
isAvoidWriteEmpty() |
ExporterCSV |
setAvoidFinalLineEnd(boolean bAvoidFinalLineEnd)
Set whether the CSV file should end with a new line or not.
|
ExporterCSV |
setAvoidWriteEmpty(boolean bAvoidWriteEmpty)
Enable or disable that empty files are written.
|
ExporterCSV |
setCharset(Charset aCharset) |
ExporterCSV |
setEscapeChar(char cEscape) |
ExporterCSV |
setLineEnd(String sLineEnd) |
ExporterCSV |
setQuoteChar(char cQuote) |
ExporterCSV |
setSeparatorChar(char cSeparator) |
ExporterCSV |
setUnicodeBOM(com.helger.commons.charset.EUnicodeBOM eBOM) |
@Nonnull public final EExchangeFileType getFileType()
getFileType in interface IExporterFile@Nonnull public final ExporterCSV setCharset(@Nonnull Charset aCharset)
public final char getSeparatorChar()
@Nonnull public final ExporterCSV setSeparatorChar(char cSeparator)
cSeparator - Separator charpublic final char getQuoteChar()
@Nonnull public final ExporterCSV setQuoteChar(char cQuote)
public final char getEscapeChar()
@Nonnull public final ExporterCSV setEscapeChar(char cEscape)
@Nonnull public final ExporterCSV setLineEnd(@Nonnull @Nonempty String sLineEnd)
@Nullable public final com.helger.commons.charset.EUnicodeBOM getUnicodeBOM()
@Nonnull public final ExporterCSV setUnicodeBOM(@Nullable com.helger.commons.charset.EUnicodeBOM eBOM)
public final boolean isAvoidWriteEmpty()
true if empty files are not written,
false otherwise (by default).@Nonnull public final ExporterCSV setAvoidWriteEmpty(boolean bAvoidWriteEmpty)
bAvoidWriteEmpty - true to collect before write, false to
write directlypublic final boolean isAvoidFinalLineEnd()
true if the written data should end with a line end,
false otherwise (by default).@Nonnull public final ExporterCSV setAvoidFinalLineEnd(boolean bAvoidFinalLineEnd)
bAvoidFinalLineEnd - true to avoid the CSV file ending with a new line.@Nonnull @OverrideOnDemand @WillCloseWhenClosed protected com.helger.commons.csv.CSVWriter createCSVWriter(@Nonnull OutputStream aOS)
aOS - The output stream to write to. May not be null.CSVWriter to used. Never null.@Nonnull public com.helger.commons.state.ESuccess exportRecords(@Nonnull IExportRecordProvider aProvider, @Nonnull @WillClose OutputStream aOS)
IExporterexportRecords in interface IExporteraProvider - The provider for all records. May not be null.aOS - The output stream to write to. Will be closed automatically in any
case. May not be null.ESuccess.SUCCESS if at lease one record was provided and
saving was successful.Copyright © 2014–2021 Philip Helger. All rights reserved.