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

public abstract Class AbstractObjectListProcessor<T extends Context>

extends AbstractObjectProcessor<T extends Context>
Class Inheritance
Known Direct Subclasses
com.univocity.parsers.common.processor.ObjectRowListProcessor
Imports
com.univocity.parsers.common.*, java.util.*

A convenience Processor implementation for storing all rows parsed and converted to Object arrays into a list. A typical use case of this class will be:
ObjectRowListProcessor processor = new ObjectRowListProcessor();
processor.convertIndexes(Conversions.toBigDecimal()).set(4, 6);
parserSettings.setRowProcessor(new ObjectRowListProcessor());
parser.parse(reader); // will invoke the {@link AbstractObjectListProcessor#rowProcessed(Object[], T)} method for each parsed record.

String[] headers = rowProcessor.getHeaders();
List<Object[]> rows = rowProcessor.getRows();
BigDecimal value1 = (BigDecimal) row.get(4);
BigDecimal value2 = (BigDecimal) row.get(6);

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

Field Summary

Modifier and TypeField and Description
private final int
private String[]
private List<Object[]>

Constructor Summary

AccessConstructor and Description
public
AbstractObjectListProcessor()

Creates a new processor of Object[] rows with varying types.

public
AbstractObjectListProcessor(int
expected number of rows to be parsed from the input. Used to pre-allocate the size of the output List returned by getRows()
expectedRowCount
)

Creates a new processor of Object[] rows with varying types.

Method Summary

Modifier and TypeMethod and Description
public String[]

Returns:

the headers of all records parsed.
getHeaders
()

Returns the record headers.

public List<Object[]>

Returns:

the list of parsed and converted records
getRows
()

Returns the list of parsed and converted records

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 void
rowProcessed(Object[]
the data extracted by the parser for an individual record and converted to an Object array.
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.

Stores the row extracted by the parser and them converted to an Object array into a list.
Inherited from com.univocity.parsers.common.processor.core.AbstractObjectProcessor:
rowProcessed

Field Detail

expectedRowCountback to summary
private final int expectedRowCount
headersback to summary
private String[] headers
rowsback to summary
private List<Object[]> rows

Constructor Detail

AbstractObjectListProcessorback to summary
public AbstractObjectListProcessor()

Creates a new processor of Object[] rows with varying types.

AbstractObjectListProcessorback to summary
public AbstractObjectListProcessor(int expectedRowCount)

Creates a new processor of Object[] rows with varying types.

Parameters
expectedRowCount:int

expected number of rows to be parsed from the input. Used to pre-allocate the size of the output List returned by getRows()

Method Detail

getHeadersback to summary
public String[] getHeaders()

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

Returns:String[]

the headers of all records parsed.

getRowsback to summary
public List<Object[]> getRows()

Returns the list of parsed and converted records

Returns:List<Object[]>

the list of parsed and converted records

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
rowProcessedback to summary
public void rowProcessed(Object[] row, T context)

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

Stores the row extracted by the parser and them converted to an Object array into a list.

Parameters
row:Object[]

the data extracted by the parser for an individual record and converted to an Object array.

context:T

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

Annotations
@Override