Class ColumnSplitter<T>

    • Constructor Summary

      Constructors 
      Constructor Description
      ColumnSplitter​(int expectedRowCount)
      Creates a splitter allocating a space for a give number of expected rows to be read
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void addValuesToColumns​(T[] row, Context context)
      Splits the row and add stores the value of each column in its corresponding list in columnValues
      (package private) void clearValues()
      Removes any column values previously processed
      (package private) java.util.List<java.util.List<T>> getColumnValues()
      Returns the values processed for each column
      (package private) <V> java.util.List<V> getColumnValues​(int columnIndex, java.lang.Class<V> columnType)
      Returns the values of a given column.
      (package private) <V> java.util.List<V> getColumnValues​(java.lang.String columnName, java.lang.Class<V> columnType)
      Returns the values of a given column.
      (package private) java.util.Map<java.lang.Integer,​java.util.List<T>> getColumnValuesAsMapOfIndexes()
      Returns a map of column indexes and their respective list of values parsed from the input.
      (package private) java.util.Map<java.lang.String,​java.util.List<T>> getColumnValuesAsMapOfNames()
      Returns a map of column names and their respective list of values parsed from the input.
      (package private) java.lang.String getHeader​(int columnIndex)
      Returns the header of a particular column
      (package private) java.lang.String[] getHeaders()
      Returns the headers of the input.
      private void initialize​(Context context)
      Initializes the list of column values, the headers of each column and which columns to read if fields have been selected using CommonSettings.selectFields(String...) or CommonSettings.selectIndexes(Integer...)
      (package private) void putColumnValuesInMapOfIndexes​(java.util.Map<java.lang.Integer,​java.util.List<T>> map)
      Fills a given map associating each column index to its list of values
      (package private) void putColumnValuesInMapOfNames​(java.util.Map<java.lang.String,​java.util.List<T>> map)
      Fills a given map associating each column name to its list o values
      (package private) void reset()
      Prepares to execute a column splitting process from the beginning.
      • Methods inherited from class java.lang.Object

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

      • columnValues

        private java.util.List<java.util.List<T>> columnValues
      • headers

        private java.lang.String[] headers
      • expectedRowCount

        private int expectedRowCount
      • rowCount

        private long rowCount
      • addNullsFrom

        private long addNullsFrom
    • Constructor Detail

      • ColumnSplitter

        ColumnSplitter​(int expectedRowCount)
        Creates a splitter allocating a space for a give number of expected rows to be read
        Parameters:
        expectedRowCount - the expected number of rows to be parsed
    • Method Detail

      • clearValues

        void clearValues()
        Removes any column values previously processed
      • reset

        void reset()
        Prepares to execute a column splitting process from the beginning. Removes any column values previously processed, as well as information about headers in the input. Resets row count to 0.
      • getColumnValues

        java.util.List<java.util.List<T>> getColumnValues()
        Returns the values processed for each column
        Returns:
        a list of lists. The stored lists correspond to the position of the column processed from the input; Each list contains the corresponding values parsed for a column, across multiple rows.
      • getHeaders

        java.lang.String[] getHeaders()
        Returns the headers of the input. This can be either the headers defined in CommonSettings.getHeaders() or the headers parsed in the input when CommonSettings.getHeaders() equals to true
        Returns:
        the headers of all records parsed.
      • getHeader

        java.lang.String getHeader​(int columnIndex)
        Returns the header of a particular column
        Parameters:
        columnIndex - the index of the column whose header is to be obtained
        Returns:
        the name of the column at the given index, or null if there's no header defined for the given column index.
      • addValuesToColumns

        void addValuesToColumns​(T[] row,
                                Context context)
        Splits the row and add stores the value of each column in its corresponding list in columnValues
        Parameters:
        row - the row whose column values will be split
        context - the current active parsing context.
      • putColumnValuesInMapOfNames

        void putColumnValuesInMapOfNames​(java.util.Map<java.lang.String,​java.util.List<T>> map)
        Fills a given map associating each column name to its list o values
        Parameters:
        map - the map to hold the values of each column
        Throws:
        java.lang.IllegalArgumentException - if a column does not have a name associated to it. In this case, use putColumnValuesInMapOfIndexes(Map) instead.
      • getColumnValues

        <V> java.util.List<V> getColumnValues​(int columnIndex,
                                              java.lang.Class<V> columnType)
        Returns the values of a given column.
        Type Parameters:
        V - the type of data in that column
        Parameters:
        columnIndex - the position of the column in the input (0-based).
        columnType - the type of data in that column
        Returns:
        a list with all data stored in the given column
      • getColumnValues

        <V> java.util.List<V> getColumnValues​(java.lang.String columnName,
                                              java.lang.Class<V> columnType)
        Returns the values of a given column.
        Type Parameters:
        V - the type of data in that column
        Parameters:
        columnName - the name of the column in the input.
        columnType - the type of data in that column
        Returns:
        a list with all data stored in the given column
      • putColumnValuesInMapOfIndexes

        void putColumnValuesInMapOfIndexes​(java.util.Map<java.lang.Integer,​java.util.List<T>> map)
        Fills a given map associating each column index to its list of values
        Parameters:
        map - the map to hold the values of each column
      • getColumnValuesAsMapOfNames

        java.util.Map<java.lang.String,​java.util.List<T>> getColumnValuesAsMapOfNames()
        Returns a map of column names and their respective list of values parsed from the input.
        Returns:
        a map of column names and their respective list of values.
      • getColumnValuesAsMapOfIndexes

        java.util.Map<java.lang.Integer,​java.util.List<T>> getColumnValuesAsMapOfIndexes()
        Returns a map of column indexes and their respective list of values parsed from the input.
        Returns:
        a map of column indexes and their respective list of values.