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

public abstract Class AbstractListProcessor<T extends Context>

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

A convenience Processor implementation for storing all rows parsed into a list. A typical use case of this class will be:

parserSettings.setRowProcessor(new RowListProcessor());
parser.parse(reader); // will invoke the AbstractListProcessor#rowProcessed(String[], Context) method for each parsed record.

String[] headers = rowProcessor.getHeaders();
List<String[]> rows = rowProcessor.getRows();


Author
Univocity Software Pty Ltd - [email protected]

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
AbstractListProcessor()

Creates a new processor of String[] rows.

public
AbstractListProcessor(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 String[] rows.

Method Summary

Modifier and TypeMethod and Description
public String[]

Returns:

the headers of all records parsed.
getHeaders
()

Returns the record headers.

public List<String[]>

Returns:

the list of parsed records
getRows
()

The list of parsed records

public void
processEnded(T
A contextual object with information and controls over the state of the parsing process
context
)

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
)

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(String[]
the data extracted by the parser for an individual record. Note that:
row
,
T
A contextual object with information and controls over the current state of the parsing process
context
)

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

Stores the row extracted by the parser into a list.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

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

Constructor Detail

AbstractListProcessorback to summary
public AbstractListProcessor()

Creates a new processor of String[] rows.

AbstractListProcessorback to summary
public AbstractListProcessor(int expectedRowCount)

Creates a new processor of String[] rows.

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<String[]> getRows()

The list of parsed records

Returns:List<String[]>

the list of parsed records

processEndedback to summary
public void processEnded(T context)

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)

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(String[] row, T context)

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

Stores the row extracted by the parser into a list.

Parameters
row:String[]

the data extracted by the parser for an individual record. Note that:

context:T

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

Annotations
@Override