Class AbstractMultiBeanListProcessor<C extends Context>
java.lang.Object
com.univocity.parsers.common.processor.core.AbstractMultiBeanProcessor<C>
com.univocity.parsers.common.processor.core.AbstractMultiBeanRowProcessor<C>
com.univocity.parsers.common.processor.core.AbstractMultiBeanListProcessor<C>
- All Implemented Interfaces:
ConversionProcessor
,Processor<C>
- Direct Known Subclasses:
MultiBeanListProcessor
public class AbstractMultiBeanListProcessor<C extends Context>
extends AbstractMultiBeanRowProcessor<C>
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
.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractMultiBeanListProcessor
(int expectedBeanCount, Class... beanTypes) Creates a processor for java beans of multiple typesAbstractMultiBeanListProcessor
(Class... beanTypes) Creates a processor for java beans of multiple types -
Method Summary
Modifier and TypeMethodDescriptiongetBeans()
Returns a map of all beans processed from the input.<T> List<T>
Returns the beans of a given type processed from the input.final String[]
Returns the record headers.final void
processEnded
(C context) This method will by invoked by the parser once, after the parsing process stopped and all resources were closed.final void
processStarted
(C context) 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> row, C context) Invoked by the processor after all beans of a valid record have been processed.Methods inherited from class com.univocity.parsers.common.processor.core.AbstractMultiBeanRowProcessor
beanProcessed
Methods inherited from class com.univocity.parsers.common.processor.core.AbstractMultiBeanProcessor
convertAll, convertFields, convertIndexes, convertType, getBeanClasses, getProcessorOfType, rowProcessed
-
Field Details
-
beanTypes
-
beans
-
headers
-
expectedBeanCount
private final int expectedBeanCount
-
-
Constructor Details
-
AbstractMultiBeanListProcessor
Creates a processor for java beans of multiple types- Parameters:
expectedBeanCount
- 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 outputList
returned bygetBeans()
beanTypes
- the classes with their attributes mapped to fields of records parsed by anAbstractParser
or written by anAbstractWriter
.
-
AbstractMultiBeanListProcessor
Creates a processor for java beans of multiple types- Parameters:
beanTypes
- the classes with their attributes mapped to fields of records parsed by anAbstractParser
or written by anAbstractWriter
.
-
-
Method Details
-
processStarted
Description copied from interface:Processor
This method will by invoked by the parser once, when it is ready to start processing the input.- Specified by:
processStarted
in interfaceProcessor<C extends Context>
- Overrides:
processStarted
in classAbstractMultiBeanRowProcessor<C extends Context>
- Parameters:
context
- A contextual object with information and controls over the current state of the parsing process
-
rowProcessed
Description copied from class:AbstractMultiBeanRowProcessor
Invoked by the processor after all beans of a valid record have been processed.- Specified by:
rowProcessed
in classAbstractMultiBeanRowProcessor<C extends Context>
- Parameters:
row
- 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
- A contextual object with information and controls over the current state of the parsing process
-
processEnded
Description copied from interface:Processor
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
Context.stop()
.- Specified by:
processEnded
in interfaceProcessor<C extends Context>
- Overrides:
processEnded
in classAbstractMultiBeanRowProcessor<C extends Context>
- Parameters:
context
- A contextual object with information and controls over the state of the parsing process
-
getHeaders
Returns the record headers. This can be either the headers defined inCommonSettings.getHeaders()
or the headers parsed in the file whenCommonSettings.getHeaders()
equals true- Returns:
- the headers of all records parsed.
-
getBeans
Returns the beans of a given type processed from the input.- Type Parameters:
T
- the type of bean processed- Parameters:
beanType
- the type of bean processed- Returns:
- a list with all beans of the given that were processed from the input. Might contain nulls.
-
getBeans
Returns a map of all beans processed from the input.- Returns:
- all beans processed from the input.
-