T
- the type of values stored in the columns.class ColumnSplitter<T>
extends java.lang.Object
Processor
. Used to centralize common code used by implementations
of ColumnReader
, namely:
AbstractColumnProcessor
, AbstractObjectColumnProcessor
, AbstractBatchedColumnProcessor
and AbstractBatchedObjectColumnProcessor
.Modifier and Type | Field and Description |
---|---|
private long |
addNullsFrom |
private java.util.List<java.util.List<T>> |
columnValues |
private int |
expectedRowCount |
private java.lang.String[] |
headers |
private long |
rowCount |
Constructor and Description |
---|
ColumnSplitter(int expectedRowCount)
Creates a splitter allocating a space for a give number of expected rows to be read
|
Modifier and Type | Method and 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.
|
private java.util.List<java.util.List<T>> columnValues
private java.lang.String[] headers
private int expectedRowCount
private long rowCount
private long addNullsFrom
ColumnSplitter(int expectedRowCount)
expectedRowCount
- the expected number of rows to be parsedvoid clearValues()
void reset()
java.util.List<java.util.List<T>> getColumnValues()
java.lang.String[] getHeaders()
CommonSettings.getHeaders()
or the headers parsed in the input when CommonSettings.getHeaders()
equals to true
private void initialize(Context context)
CommonSettings.selectFields(String...)
or CommonSettings.selectIndexes(Integer...)
context
- the current active parsing context, which will be used to obtain information about headers and selected fields.java.lang.String getHeader(int columnIndex)
columnIndex
- the index of the column whose header is to be obtainedvoid addValuesToColumns(T[] row, Context context)
columnValues
row
- the row whose column values will be splitcontext
- the current active parsing context.void putColumnValuesInMapOfNames(java.util.Map<java.lang.String,java.util.List<T>> map)
map
- the map to hold the values of each columnjava.lang.IllegalArgumentException
- if a column does not have a name associated to it. In this case, use putColumnValuesInMapOfIndexes(Map)
instead.<V> java.util.List<V> getColumnValues(int columnIndex, java.lang.Class<V> columnType)
V
- the type of data in that columncolumnIndex
- the position of the column in the input (0-based).columnType
- the type of data in that column<V> java.util.List<V> getColumnValues(java.lang.String columnName, java.lang.Class<V> columnType)
V
- the type of data in that columncolumnName
- the name of the column in the input.columnType
- the type of data in that columnvoid putColumnValuesInMapOfIndexes(java.util.Map<java.lang.Integer,java.util.List<T>> map)
map
- the map to hold the values of each columnjava.util.Map<java.lang.String,java.util.List<T>> getColumnValuesAsMapOfNames()
java.util.Map<java.lang.Integer,java.util.List<T>> getColumnValuesAsMapOfIndexes()