Interface ICsvBeanWriter

  • All Superinterfaces:
    java.lang.AutoCloseable, java.io.Closeable, java.io.Flushable, ICsvWriter
    All Known Implementing Classes:
    CsvBeanWriter

    public interface ICsvBeanWriter
    extends ICsvWriter
    Interface for all CSV writers writing to beans.
    Author:
    Kasper B. Graversen
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void write​(java.lang.Object source, java.lang.String... nameMapping)
      Writes the fields of the object as columns of a CSV file, using the supplied name mapping to map fields to the appropriate columns.
      void write​(java.lang.Object source, java.lang.String[] nameMapping, CellProcessor[] processors)
      Writes the fields of the object as columns of a CSV file, using the supplied name mapping to map fields to the appropriate columns.
      • Methods inherited from interface java.io.Closeable

        close
      • Methods inherited from interface java.io.Flushable

        flush
    • Method Detail

      • write

        void write​(java.lang.Object source,
                   java.lang.String... nameMapping)
            throws java.io.IOException
        Writes the fields of the object as columns of a CSV file, using the supplied name mapping to map fields to the appropriate columns. toString() will be called on each element prior to writing.
        Parameters:
        source - the object (bean instance) containing the values to write
        nameMapping - an array of Strings linking the fields in the bean to their corresponding CSV columns (the array length should match the number of columns). A null entry in the array indicates that the column should be ignored (the column will be empty).
        Throws:
        java.io.IOException - if an I/O error occurred
        java.lang.NullPointerException - if source or nameMapping are null
        SuperCsvException - if there was a general exception while writing
        SuperCsvReflectionException - if there was an reflection exception while mapping the values from the bean
        Since:
        1.0
      • write

        void write​(java.lang.Object source,
                   java.lang.String[] nameMapping,
                   CellProcessor[] processors)
            throws java.io.IOException
        Writes the fields of the object as columns of a CSV file, using the supplied name mapping to map fields to the appropriate columns. toString() will be called on each (processed) element prior to writing.
        Parameters:
        source - the object (bean instance) containing the values to write
        nameMapping - an array of Strings linking the fields in the bean to their corresponding CSV columns (the array length should match the number of columns). A null entry in the array indicates that the column should be ignored (the column will be empty).
        processors - an array of CellProcessors used to further process data before it is written (each element in the processors array corresponds with a CSV column - the number of processors should match the number of columns). A null entry indicates no further processing is required (the value returned by toString() will be written as the column value).
        Throws:
        java.io.IOException - if an I/O error occurred
        java.lang.NullPointerException - if source, nameMapping or processors are null
        SuperCsvConstraintViolationException - if a CellProcessor constraint failed
        SuperCsvException - if there was a general exception while writing/processing
        SuperCsvReflectionException - if there was an reflection exception while mapping the values from the bean
        Since:
        1.29