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

public abstract Class AbstractBeanListProcessor<T, C extends Context>

extends AbstractBeanProcessor<T, C extends Context>
Class Inheritance
Known Direct Subclasses
com.univocity.parsers.common.processor.BeanListProcessor
Type Parameters
<T>
the annotated class type.
Imports
com.univocity.parsers.annotations.helpers.*, com.univocity.parsers.common.*, java.util.*

A convenience Processor implementation for storing all java objects generated form the parsed input into a list. A typical use case of this class will be:
parserSettings.setRowProcessor(new BeanListProcessor(MyObject.class));
parser.parse(reader); // will invoke the {@link AbstractBeanListProcessor#beanProcessed(Object, C)} method for each generated object.

List<T> beans = rowProcessor.getBeans();

Author
Univocity Software Pty Ltd - [email protected]
See Also
Processor, AbstractParser, AbstractBeanProcessor, BeanConversionProcessor

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
AbstractBeanListProcessor(Class<T>
the class with its attributes mapped to fields of records parsed by an AbstractParser or written by an AbstractWriter.
beanType
)

Creates a processor that stores java beans of a given type into a list

public
AbstractBeanListProcessor(Class<T>
the class with its attributes mapped to fields of records parsed by an AbstractParser or written by an AbstractWriter.
beanType
,
int
expected number of rows to be parsed from the input which will be converted into java beans. Used to pre-allocate the size of the output List returned by getBeans()
expectedBeanCount
)

Creates a processor that stores java beans of a given type into a list

Method Summary

Modifier and TypeMethod and Description
public void
beanProcessed(T
java bean generated with the information extracted by the parser for an individual record
bean
,
C
A contextual object with information and controls over the current state of the parsing process
context
)

Implements abstract com.univocity.parsers.common.processor.core.AbstractBeanProcessor.beanProcessed.

Stores the generated java bean produced with a parsed record into a list.
public List<T>

Returns:

the list of generated java beans at the end of the parsing process.
getBeans
()

Returns the list of generated java beans at the end of the parsing process.

public String[]

Returns:

the headers of all records parsed.
getHeaders
()

Returns the record headers.

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

Overrides com.univocity.parsers.common.processor.core.AbstractBeanProcessor.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(C
A contextual object with information and controls over the current state of the parsing process
context
)

Overrides com.univocity.parsers.common.processor.core.AbstractBeanProcessor.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.
Inherited from com.univocity.parsers.common.processor.core.AbstractBeanProcessor:
rowProcessed

Field Detail

beansback to summary
private List<T> beans
expectedBeanCountback to summary
private final int expectedBeanCount
headersback to summary
private String[] headers

Constructor Detail

AbstractBeanListProcessorback to summary
public AbstractBeanListProcessor(Class<T> beanType)

Creates a processor that stores java beans of a given type into a list

Parameters
beanType:Class<T>

the class with its attributes mapped to fields of records parsed by an AbstractParser or written by an AbstractWriter.

AbstractBeanListProcessorback to summary
public AbstractBeanListProcessor(Class<T> beanType, int expectedBeanCount)

Creates a processor that stores java beans of a given type into a list

Parameters
beanType:Class<T>

the class with its attributes mapped to fields of records parsed by an AbstractParser or written by an AbstractWriter.

expectedBeanCount:int

expected number of rows to be parsed from the input which will be converted into java beans. Used to pre-allocate the size of the output List returned by getBeans()

Method Detail

beanProcessedback to summary
public void beanProcessed(T bean, C context)

Implements abstract com.univocity.parsers.common.processor.core.AbstractBeanProcessor.beanProcessed.

Stores the generated java bean produced with a parsed record into a list.

Parameters
bean:T

java bean generated with the information extracted by the parser for an individual record

context:C

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

Annotations
@Override
See Also
com.univocity.parsers.common.processor.BeanProcessor
getBeansback to summary
public List<T> getBeans()

Returns the list of generated java beans at the end of the parsing process.

Returns:List<T>

the list of generated java beans at the end of the parsing process.

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.

processEndedback to summary
public void processEnded(C context)

Overrides com.univocity.parsers.common.processor.core.AbstractBeanProcessor.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:C

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

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

Overrides com.univocity.parsers.common.processor.core.AbstractBeanProcessor.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:C

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

Annotations
@Override