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

public abstract Class AbstractBatchedObjectColumnProcessor<T extends Context>

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

A Processor implementation for converting batches of 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.

During the execution of the process, the batchProcessed(int) method will be invoked after a given number of rows has been processed.

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

After batchProcessed(int) is invoked, all values will be discarded and the next batch of column values will be accumulated. This process will repeat until there's no more rows in the input.

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

Field Summary

Modifier and TypeField and Description
private int
private int
private final int
private final ColumnSplitter<Object>

Constructor Summary

AccessConstructor and Description
public
AbstractBatchedObjectColumnProcessor(int
the number of rows to process in each batch.
rowsPerBatch
)

Constructs a abstract batched column processor configured to invoke the batchesProcessed method after a given number of rows has been processed.

Method Summary

Modifier and TypeMethod and Description
public abstract void
batchProcessed(int
the number of rows processed in the current batch. This corresponds to the number of elements of each list of each column.
rowsInThisBatch
)

Redeclares com.univocity.parsers.common.processor.core.BatchedColumnReader.batchProcessed.

Callback to the user, where the lists with values parsed for all columns can be accessed using the methods getColumnValuesAsList(), getColumnValuesAsMapOfIndexes() and getColumnValuesAsMapOfNames().
public int
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 <
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 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 int
getRowsPerBatch()

Implements com.univocity.parsers.common.processor.core.BatchedColumnReader.getRowsPerBatch.

Returns the number of rows processed in each batch
public void
processEnded(T
A contextual object with information and controls over the state of the parsing process
context
)

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

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

This method will by invoked by the parser once, after the parsing process stopped and all resources were closed.
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:
rowProcessed

Field Detail

batchCountback to summary
private int batchCount
batchesProcessedback to summary
private int batchesProcessed
rowsPerBatchback to summary
private final int rowsPerBatch
splitterback to summary
private final ColumnSplitter<Object> splitter

Constructor Detail

AbstractBatchedObjectColumnProcessorback to summary
public AbstractBatchedObjectColumnProcessor(int rowsPerBatch)

Constructs a abstract batched column processor configured to invoke the batchesProcessed method after a given number of rows has been processed.

Parameters
rowsPerBatch:int

the number of rows to process in each batch.

Method Detail

batchProcessedback to summary
public abstract void batchProcessed(int rowsInThisBatch)

Redeclares com.univocity.parsers.common.processor.core.BatchedColumnReader.batchProcessed.

Doc from com.univocity.parsers.common.processor.core.BatchedColumnReader.batchProcessed.

Callback to the user, where the lists with values parsed for all columns can be accessed using the methods getColumnValuesAsList(), getColumnValuesAsMapOfIndexes() and getColumnValuesAsMapOfNames().

Parameters
rowsInThisBatch:int

the number of rows processed in the current batch. This corresponds to the number of elements of each list of each column.

Annotations
@Override
getBatchesProcessedback to summary
public int getBatchesProcessed()

Implements com.univocity.parsers.common.processor.core.BatchedColumnReader.getBatchesProcessed.

Doc from com.univocity.parsers.common.processor.core.BatchedColumnReader.getBatchesProcessed.

Returns the number of batches already processed

Returns:int

the number of batches already processed

Annotations
@Override
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
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

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
getRowsPerBatchback to summary
public int getRowsPerBatch()

Implements com.univocity.parsers.common.processor.core.BatchedColumnReader.getRowsPerBatch.

Doc from com.univocity.parsers.common.processor.core.BatchedColumnReader.getRowsPerBatch.

Returns the number of rows processed in each batch

Returns:int

the number of rows per batch

Annotations
@Override
processEndedback to summary
public void processEnded(T context)

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

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

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

This method will by invoked by the parser once, after the parsing process stopped and all resources were closed.

It will always be called by the parser: in case of errors, if the end of the input us reached, or if the user stopped the process manually using ParsingContext#stop().

Parameters
context:T

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

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