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

public Class AbstractMultiBeanListProcessor<C extends Context>

extends AbstractMultiBeanRowProcessor<C extends Context>
Class Inheritance
Known Direct Subclasses
com.univocity.parsers.common.processor.MultiBeanListProcessor
Imports
com.univocity.parsers.annotations.helpers.*, com.univocity.parsers.common.*, java.util.*

A Processor implementation for converting rows extracted from any implementation of AbstractParser into java objects, storing them into lists. This processor stores beans in separate lists, one for each type of bean processed. All lists of all types will have the same number of entries as the number of records in the input. When an object of a particular type can't be generated from a row, null will be added to the list. This ensures all lists are the same size, and each element of each list contains the exact information parsed from each row.

The class types passed to the constructor of this class must contain the annotations provided in com.univocity.parsers.annotations.

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

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
AbstractMultiBeanListProcessor(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
,
Class<T>...
the classes with their attributes mapped to fields of records parsed by an AbstractParser or written by an AbstractWriter.
beanTypes
)

Creates a processor for java beans of multiple types

public
AbstractMultiBeanListProcessor(Class<T>...
the classes with their attributes mapped to fields of records parsed by an AbstractParser or written by an AbstractWriter.
beanTypes
)

Creates a processor for java beans of multiple types

Method Summary

Modifier and TypeMethod and Description
public <
the type of bean processed
T
>
List<T>

Returns:

a list with all beans of the given that were processed from the input. Might contain nulls.
getBeans
(Class<T>
the type of bean processed
beanType
)

Returns the beans of a given type processed from the input.

public Map<Class<?>, List<?>>

Returns:

all beans processed from the input.
getBeans
()

Returns a map of all beans processed from the input.

public final String[]

Returns:

the headers of all records parsed.
getHeaders
()

Returns the record headers.

public final 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.AbstractMultiBeanRowProcessor.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 final 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.AbstractMultiBeanRowProcessor.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.
protected final void
rowProcessed(Map<Class<?>, Object>
a map containing all object instances generated from an input row. The map is reused internally. Make a copy if you want to keep the map.
row
,
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.AbstractMultiBeanRowProcessor.rowProcessed.

Invoked by the processor after all beans of a valid record have been processed.
Inherited from com.univocity.parsers.common.processor.core.AbstractMultiBeanRowProcessor:
beanProcessed

Field Detail

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

Constructor Detail

AbstractMultiBeanListProcessorback to summary
public AbstractMultiBeanListProcessor(int expectedBeanCount, Class<T>... beanTypes)

Creates a processor for java beans of multiple types

Parameters
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()

beanTypes:Class<T>[]

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

AbstractMultiBeanListProcessorback to summary
public AbstractMultiBeanListProcessor(Class<T>... beanTypes)

Creates a processor for java beans of multiple types

Parameters
beanTypes:Class<T>[]

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

Method Detail

getBeansback to summary
public <T> List<T> getBeans(Class<T> beanType)

Returns the beans of a given type processed from the input.

Parameters
<T>
the type of bean processed
beanType:Class<T>

the type of bean processed

Returns:List<T>

a list with all beans of the given that were processed from the input. Might contain nulls.

getBeansback to summary
public Map<Class<?>, List<?>> getBeans()

Returns a map of all beans processed from the input.

Returns:Map<Class<?>, List<?>>

all beans processed from the input.

getHeadersback to summary
public final 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 final void processEnded(C context)

Overrides com.univocity.parsers.common.processor.core.AbstractMultiBeanRowProcessor.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 final void processStarted(C context)

Overrides com.univocity.parsers.common.processor.core.AbstractMultiBeanRowProcessor.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
rowProcessedback to summary
protected final void rowProcessed(Map<Class<?>, Object> row, C context)

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

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

Invoked by the processor after all beans of a valid record have been processed.

Parameters
row:Map<Class<?>, Object>

a map containing all object instances generated from an input row. The map is reused internally. Make a copy if you want to keep the map.

context:C

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

Annotations
@Override