Class CsvExporter


  • public class CsvExporter
    extends java.lang.Object
    Class for exporting data to CSV.
    • Constructor Summary

      Constructors 
      Constructor Description
      CsvExporter​(int numCols, java.lang.String... headers)
      Creates a new CSV exporter with the given number of data columns and column header.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addRow​(java.lang.Object... data)
      Appends a data row to the bottom of the table.
      void addRow​(java.util.List<?> data)
      Appends a data row to the bottom of the table.
      void clear()
      Clears the stored data in the exporter.
      java.lang.String export()
      Exports a CSV table.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CsvExporter

        public CsvExporter​(int numCols,
                           java.lang.String... headers)
        Creates a new CSV exporter with the given number of data columns and column header.
        Parameters:
        numCols - the number of columns in the data table
        headers - the column headers to use
    • Method Detail

      • addRow

        public void addRow​(java.util.List<?> data)
        Appends a data row to the bottom of the table.
        Parameters:
        data - the row to append
        Throws:
        java.lang.NullPointerException - if data is null, or if it contains null elements
        java.lang.IllegalArgumentException - if the number of elements in data is not exactly equal to the number of columns specified in the constructor
        See Also:
        addRow(Object...)
      • addRow

        public void addRow​(java.lang.Object... data)
        Appends a data row to the bottom of the table.
        Parameters:
        data - the row to append
        Throws:
        java.lang.NullPointerException - if data is null, or if it contains null elements
        java.lang.IllegalArgumentException - if the number of elements in data is not exactly equal to the number of columns specified in the constructor
      • clear

        public void clear()
        Clears the stored data in the exporter. The headers are unaffected.
      • export

        public java.lang.String export()
        Exports a CSV table.
        Returns:
        the CSV representation of the data given to this exporter