public class AbstractMultiBeanListProcessor<C extends Context> extends AbstractMultiBeanRowProcessor<C>
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
.
AbstractParser
,
Processor
,
AbstractBeanProcessor
,
AbstractMultiBeanProcessor
Constructor and Description |
---|
AbstractMultiBeanListProcessor(Class... beanTypes)
Creates a processor for java beans of multiple types
|
Modifier and Type | Method and Description |
---|---|
Map<Class<?>,List<?>> |
getBeans()
Returns a map of all beans processed from the input.
|
<T> List<T> |
getBeans(Class<T> beanType)
Returns the beans of a given type processed from the input.
|
String[] |
getHeaders()
Returns the record headers.
|
void |
processEnded(C context)
This method will by invoked by the parser once, after the parsing process stopped and all resources were closed.
|
void |
processStarted(C context)
This method will by invoked by the parser once, when it is ready to start processing the input.
|
protected void |
rowProcessed(Map<Class<?>,Object> row,
C context)
Invoked by the processor after all beans of a valid record have been processed.
|
beanProcessed
convertAll, convertFields, convertIndexes, convertType, getBeanClasses, getProcessorOfType, rowProcessed
public AbstractMultiBeanListProcessor(Class... beanTypes)
beanTypes
- the classes with their attributes mapped to fields of records parsed by an AbstractParser
or written by an AbstractWriter
.public final void processStarted(C context)
Processor
processStarted
in interface Processor<C extends Context>
processStarted
in class AbstractMultiBeanRowProcessor<C extends Context>
context
- A contextual object with information and controls over the current state of the parsing processprotected final void rowProcessed(Map<Class<?>,Object> row, C context)
AbstractMultiBeanRowProcessor
rowProcessed
in class AbstractMultiBeanRowProcessor<C extends Context>
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 processpublic final void processEnded(C context)
Processor
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()
.
processEnded
in interface Processor<C extends Context>
processEnded
in class AbstractMultiBeanRowProcessor<C extends Context>
context
- A contextual object with information and controls over the state of the parsing processpublic final String[] getHeaders()
CommonSettings.getHeaders()
or the headers parsed in the file when CommonSettings.getHeaders()
equals truepublic <T> List<T> getBeans(Class<T> beanType)
T
- the type of bean processedbeanType
- the type of bean processedCopyright © 2019 uniVocity Software Pty Ltd. All rights reserved.