Class ExporterCSV

    • Constructor Detail

      • ExporterCSV

        public ExporterCSV()
    • Method Detail

      • 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()
      • getEscapeChar

        public final char getEscapeChar()
      • getUnicodeBOM

        @Nullable
        public final com.helger.commons.charset.EUnicodeBOM getUnicodeBOM()
      • 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.