Interface ICsvListReader

  • All Superinterfaces:
    java.lang.AutoCloseable, java.io.Closeable, ICsvReader
    All Known Implementing Classes:
    CsvListReader

    public interface ICsvListReader
    extends ICsvReader
    Interface for readers that read into Lists.
    Author:
    Kasper B. Graversen, James Bassett
    • Method Detail

      • read

        java.util.List<java.lang.String> read()
                                       throws java.io.IOException
        Reads a row of a CSV file and returns a List of Strings containing each column. If you are forced to use this method instead of read(CellProcessor...) because your CSV file has a variable number of columns, then you can call the executeProcessors(CellProcessor...) method after calling read() to execute the cell processors manually (after determining the number of columns read in and which cell processors to use).
        Returns:
        the List of columns, or null if EOF
        Throws:
        java.io.IOException - if an I/O error occurred
        SuperCsvException - if there was a general exception while reading/processing
        Since:
        1.0
      • read

        java.util.List<java.lang.Object> read​(CellProcessor... processors)
                                       throws java.io.IOException
        Reads a row of a CSV file and returns a List of Objects containing each column. The data can be further processed by cell processors (each element in the processors array corresponds with a CSV column). A null entry in the processors array indicates no further processing is required (the unprocessed String value will be added to the List). Prior to version 2.0.0 this method returned a List of Strings.
        Parameters:
        processors - an array of CellProcessors used to further process data before it is added to the List (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 unprocessed String value will be added to the List).
        Returns:
        the List of columns, or null if EOF
        Throws:
        java.io.IOException - if an I/O error occurred
        java.lang.NullPointerException - if processors is null
        SuperCsvConstraintViolationException - if a CellProcessor constraint failed
        SuperCsvException - if there was a general exception while reading/processing
        Since:
        1.0
      • executeProcessors

        java.util.List<java.lang.Object> executeProcessors​(CellProcessor... processors)
        Executes the supplied cell processors on the last row of CSV that was read. This should only be used when the number of CSV columns is unknown before the row is read, and you are forced to use read() instead of read(CellProcessor...).
        Parameters:
        processors - an array of CellProcessors used to further process the last row of CSV data that was read (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 unprocessed String value will be added to the List).
        Returns:
        the List of processed columns
        Throws:
        java.lang.NullPointerException - if processors is null
        SuperCsvConstraintViolationException - if a CellProcessor constraint failed
        SuperCsvException - if the wrong number of processors are supplied, or CellProcessor execution failed
        Since:
        2.1.0