Top Description Fields Constructors Methods
com.univocity.parsers.common.processor.core

public abstract Class AbstractObjectColumnProcessor<T extends Context>

extends AbstractObjectProcessor<T extends Context>
implements ColumnReader<Object>
Class Inheritance
All Implemented Interfaces
com.univocity.parsers.common.processor.core.ColumnReader
Known Direct Subclasses
com.univocity.parsers.common.processor.ObjectColumnProcessor
Imports
com.univocity.parsers.common.*, com.univocity.parsers.conversions.*, java.util.*

A Processor implementation for converting rows extracted from any implementation of AbstractParser into columns of objects.

This uses the value conversions provided by Conversion instances.

For each row processed, a sequence of conversions will be executed to generate the appropriate object. Each resulting object will then be stored in a list that contains the values of the corresponding column.

At the end of the process, the user can access the lists with values parsed for all columns using the methods getColumnValuesAsList(), getColumnValuesAsMapOfIndexes() and getColumnValuesAsMapOfNames().

Note

Storing the values of all columns may be memory intensive. For large inputs, use a AbstractBatchedObjectColumnProcessor instead

Author
Univocity Software Pty Ltd - [email protected]
See Also
AbstractParser, Processor, ColumnReader, Conversion, AbstractObjectProcessor

Field Summary

Modifier and TypeField and Description
private final ColumnSplitter<Object>

Constructor Summary

AccessConstructor and Description
public
AbstractObjectColumnProcessor()

Constructs a column processor, pre-allocating room for 1000 rows.

public
AbstractObjectColumnProcessor(int
the expected number of rows to be processed
expectedRowCount
)

Constructs a column processor pre-allocating room for the expected number of rows to be processed

Method Summary

Modifier and TypeMethod and Description
public <
the type of data in that column
V
>
List<V>

Returns:

a list with all data stored in the given column
getColumn
(String
the name of the column in the input.
columnName
,
Class<V>
the type of data in that column
columnType
)

Returns the values of a given column.

public <
the type of data in that column
V
>
List<V>

Returns:

a list with all data stored in the given column
getColumn
(int
the position of the column in the input (0-based).
columnIndex
,
Class<V>
the type of data in that column
columnType
)

Returns the values of a given column.

public List<Object>
getColumn(String
the name of the column in the input.
columnName
)

Implements com.univocity.parsers.common.processor.core.ColumnReader.getColumn.

Returns the values of a given column.
public List<Object>
getColumn(int
the position of the column in the input (0-based).
columnIndex
)

Implements com.univocity.parsers.common.processor.core.ColumnReader.getColumn.

Returns the values of a given column.
public final List<List<Object>>
public final Map<Integer, List<Object>>
getColumnValuesAsMapOfIndexes()

Implements com.univocity.parsers.common.processor.core.ColumnReader.getColumnValuesAsMapOfIndexes.

Returns a map of column indexes and their respective list of values parsed from the input.
public final Map<String, List<Object>>
getColumnValuesAsMapOfNames()

Implements com.univocity.parsers.common.processor.core.ColumnReader.getColumnValuesAsMapOfNames.

Returns a map of column names and their respective list of values parsed from the input.
public final String[]
public void
processStarted(T
A contextual object with information and controls over the current state of the parsing process
context
)

Overrides com.univocity.parsers.common.processor.core.AbstractObjectProcessor.processStarted.

Implements com.univocity.parsers.common.processor.core.Processor.processStarted.

This method will by invoked by the parser once, when it is ready to start processing the input.
public final void
putColumnValuesInMapOfIndexes(Map<Integer, List<Object>>
the map to hold the values of each column
map
)

Implements com.univocity.parsers.common.processor.core.ColumnReader.putColumnValuesInMapOfIndexes.

Fills a given map associating each column index to its list of values
public final void
putColumnValuesInMapOfNames(Map<String, List<Object>>
the map to hold the values of each column
map
)

Implements com.univocity.parsers.common.processor.core.ColumnReader.putColumnValuesInMapOfNames.

Fills a given map associating each column name to its list o values
public void
rowProcessed(Object[]
object array created with the information extracted by the parser and then converted.
row
,
T
A contextual object with information and controls over the current state of the parsing process
context
)

Implements abstract com.univocity.parsers.common.processor.core.AbstractObjectProcessor.rowProcessed.

Invoked by the processor after all values of a valid record have been processed and converted into an Object array.
Inherited from com.univocity.parsers.common.processor.core.AbstractObjectProcessor:
processEndedrowProcessed

Field Detail

splitterback to summary
private final ColumnSplitter<Object> splitter

Constructor Detail

AbstractObjectColumnProcessorback to summary
public AbstractObjectColumnProcessor()

Constructs a column processor, pre-allocating room for 1000 rows.

AbstractObjectColumnProcessorback to summary
public AbstractObjectColumnProcessor(int expectedRowCount)

Constructs a column processor pre-allocating room for the expected number of rows to be processed

Parameters
expectedRowCount:int

the expected number of rows to be processed

Method Detail

getColumnback to summary
public <V> List<V> getColumn(String columnName, Class<V> columnType)

Returns the values of a given column.

Parameters
<V>
the type of data in that column
columnName:String

the name of the column in the input.

columnType:Class<V>

the type of data in that column

Returns:List<V>

a list with all data stored in the given column

getColumnback to summary
public <V> List<V> getColumn(int columnIndex, Class<V> columnType)

Returns the values of a given column.

Parameters
<V>
the type of data in that column
columnIndex:int

the position of the column in the input (0-based).

columnType:Class<V>

the type of data in that column

Returns:List<V>

a list with all data stored in the given column

getColumnback to summary
public List<Object> getColumn(String columnName)

Implements com.univocity.parsers.common.processor.core.ColumnReader.getColumn.

Doc from com.univocity.parsers.common.processor.core.ColumnReader.getColumn.

Returns the values of a given column.

Parameters
columnName:String

the name of the column in the input.

Returns:List<Object>

a list with all data stored in the given column

Annotations
@Override
getColumnback to summary
public List<Object> getColumn(int columnIndex)

Implements com.univocity.parsers.common.processor.core.ColumnReader.getColumn.

Doc from com.univocity.parsers.common.processor.core.ColumnReader.getColumn.

Returns the values of a given column.

Parameters
columnIndex:int

the position of the column in the input (0-based).

Returns:List<Object>

a list with all data stored in the given column

Annotations
@Override
getColumnValuesAsListback to summary
public final List<List<Object>> getColumnValuesAsList()

Implements com.univocity.parsers.common.processor.core.ColumnReader.getColumnValuesAsList.

Doc from com.univocity.parsers.common.processor.core.ColumnReader.getColumnValuesAsList.

Returns the values processed for each column

Returns:List<List<Object>>

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.

Annotations
@Override
getColumnValuesAsMapOfIndexesback to summary
public final Map<Integer, List<Object>> getColumnValuesAsMapOfIndexes()

Implements com.univocity.parsers.common.processor.core.ColumnReader.getColumnValuesAsMapOfIndexes.

Doc from com.univocity.parsers.common.processor.core.ColumnReader.getColumnValuesAsMapOfIndexes.

Returns a map of column indexes and their respective list of values parsed from the input.

Returns:Map<Integer, List<Object>>

a map of column indexes and their respective list of values.

Annotations
@Override
getColumnValuesAsMapOfNamesback to summary
public final Map<String, List<Object>> getColumnValuesAsMapOfNames()

Implements com.univocity.parsers.common.processor.core.ColumnReader.getColumnValuesAsMapOfNames.

Doc from com.univocity.parsers.common.processor.core.ColumnReader.getColumnValuesAsMapOfNames.

Returns a map of column names and their respective list of values parsed from the input.

Returns:Map<String, List<Object>>

a map of column names and their respective list of values.

Annotations
@Override
getHeadersback to summary
public final String[] getHeaders()

Implements com.univocity.parsers.common.processor.core.ColumnReader.getHeaders.

Doc from com.univocity.parsers.common.processor.core.ColumnReader.getHeaders.

Returns the column headers. This can be either the headers defined in CommonSettings#getHeaders() or the headers parsed in the input when CommonSettings#getHeaders() equals to true

Returns:String[]

the headers of all column parsed.

Annotations
@Override
processStartedback to summary
public void processStarted(T context)

Overrides com.univocity.parsers.common.processor.core.AbstractObjectProcessor.processStarted.

Implements com.univocity.parsers.common.processor.core.Processor.processStarted.

Doc from com.univocity.parsers.common.processor.core.Processor.processStarted.

This method will by invoked by the parser once, when it is ready to start processing the input.

Parameters
context:T

A contextual object with information and controls over the current state of the parsing process

Annotations
@Override
putColumnValuesInMapOfIndexesback to summary
public final void putColumnValuesInMapOfIndexes(Map<Integer, List<Object>> map)

Implements com.univocity.parsers.common.processor.core.ColumnReader.putColumnValuesInMapOfIndexes.

Doc from com.univocity.parsers.common.processor.core.ColumnReader.putColumnValuesInMapOfIndexes.

Fills a given map associating each column index to its list of values

Parameters
map:Map<Integer, List<Object>>

the map to hold the values of each column

Annotations
@Override
putColumnValuesInMapOfNamesback to summary
public final void putColumnValuesInMapOfNames(Map<String, List<Object>> map)

Implements com.univocity.parsers.common.processor.core.ColumnReader.putColumnValuesInMapOfNames.

Doc from com.univocity.parsers.common.processor.core.ColumnReader.putColumnValuesInMapOfNames.

Fills a given map associating each column name to its list o values

Parameters
map:Map<String, List<Object>>

the map to hold the values of each column

Annotations
@Override
rowProcessedback to summary
public void rowProcessed(Object[] row, T context)

Implements abstract com.univocity.parsers.common.processor.core.AbstractObjectProcessor.rowProcessed.

Doc from com.univocity.parsers.common.processor.core.AbstractObjectProcessor.rowProcessed.

Invoked by the processor after all values of a valid record have been processed and converted into an Object array.

Parameters
row:Object[]

object array created with the information extracted by the parser and then converted.

context:T

A contextual object with information and controls over the current state of the parsing process

Annotations
@Override