java.lang.Object
com.helger.photon.exchange.bulkexport.format.ExporterCSV
All Implemented Interfaces:
IExporter, IExporterFile

@NotThreadSafe public class ExporterCSV extends Object implements IExporterFile
Implementation of IExporterFile for CSV files.
Author:
Philip Helger
  • Constructor Details

    • ExporterCSV

      public ExporterCSV()
    • ExporterCSV

      public ExporterCSV(@Nonnull Charset aCharset)
  • Method Details

    • getFileType

      @Nonnull public final EExchangeFileType getFileType()
      Specified by:
      getFileType in interface IExporterFile
      Returns:
      The file type for export.
    • getCharset

      @Nonnull public final Charset getCharset()
    • setCharset

      @Nonnull public final ExporterCSV setCharset(@Nonnull Charset aCharset)
    • getSeparatorChar

      public final char getSeparatorChar()
      Returns:
      Current separator char
    • setSeparatorChar

      @Nonnull public final ExporterCSV setSeparatorChar(char cSeparator)
      Parameters:
      cSeparator - Separator char
      Returns:
      this for chaining
    • getQuoteChar

      public final char getQuoteChar()
    • setQuoteChar

      @Nonnull public final ExporterCSV setQuoteChar(char cQuote)
    • getEscapeChar

      public final char getEscapeChar()
    • setEscapeChar

      @Nonnull public final ExporterCSV setEscapeChar(char cEscape)
    • getLineEnd

      @Nonnull @Nonempty public final String getLineEnd()
    • setLineEnd

      @Nonnull public final ExporterCSV setLineEnd(@Nonnull @Nonempty String sLineEnd)
    • getUnicodeBOM

      @Nullable public final com.helger.commons.charset.EUnicodeBOM getUnicodeBOM()
    • setUnicodeBOM

      @Nonnull public final ExporterCSV setUnicodeBOM(@Nullable com.helger.commons.charset.EUnicodeBOM eBOM)
    • isAvoidWriteEmpty

      public final boolean isAvoidWriteEmpty()
      Returns:
      true if empty files are not written, false otherwise (by default).
    • setAvoidWriteEmpty

      @Nonnull public final ExporterCSV setAvoidWriteEmpty(boolean bAvoidWriteEmpty)
      Enable or disable that empty files are written. By enabling this, all records are collected which results in higher memory consumption but safer output. If this is disabled (the default) than it my happen that nothing is written on the output stream.
      Parameters:
      bAvoidWriteEmpty - true to collect before write, false to write directly
      Returns:
      this for chaining
      Since:
      7.0.4
    • isAvoidFinalLineEnd

      public final boolean isAvoidFinalLineEnd()
      Returns:
      true if the written data should end with a line end, false otherwise (by default).
      Since:
      7.1.1
    • setAvoidFinalLineEnd

      @Nonnull public final ExporterCSV setAvoidFinalLineEnd(boolean bAvoidFinalLineEnd)
      Set whether the CSV file should end with a new line or not.
      Parameters:
      bAvoidFinalLineEnd - true to avoid the CSV file ending with a new line.
      Returns:
      this for chaining
      Since:
      7.1.1
    • createCSVWriter

      @Nonnull @OverrideOnDemand @WillCloseWhenClosed protected com.helger.commons.csv.CSVWriter createCSVWriter(@Nonnull OutputStream aOS)
      Create a new CSV writer.
      Parameters:
      aOS - The output stream to write to. May not be null.
      Returns:
      The CSVWriter to used. Never null.
    • exportRecords

      @Nonnull public com.helger.commons.state.ESuccess exportRecords(@Nonnull IExportRecordProvider aProvider, @Nonnull @WillClose OutputStream aOS)
      Description copied from interface: IExporter
      Export all provided records to an output stream.
      Specified by:
      exportRecords in interface IExporter
      Parameters:
      aProvider - 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.
      Returns:
      ESuccess.SUCCESS if at lease one record was provided and saving was successful.