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>
AProcessorimplementation for converting rows extracted from any implementation ofAbstractParserinto 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,nullwill 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 Modifier and Type Field Description private java.util.List[]beansprivate java.lang.Class[]beanTypesprivate intexpectedBeanCountprivate java.lang.String[]headers
-
Constructor Summary
Constructors Constructor Description AbstractMultiBeanListProcessor(int expectedBeanCount, java.lang.Class... beanTypes)Creates a processor for java beans of multiple typesAbstractMultiBeanListProcessor(java.lang.Class... beanTypes)Creates a processor for java beans of multiple types
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.Class<?>,java.util.List<?>>getBeans()Returns a map of all beans processed from the input.<T> java.util.List<T>getBeans(java.lang.Class<T> beanType)Returns the beans of a given type processed from the input.java.lang.String[]getHeaders()Returns the record headers.voidprocessEnded(C context)This method will by invoked by the parser once, after the parsing process stopped and all resources were closed.voidprocessStarted(C context)This method will by invoked by the parser once, when it is ready to start processing the input.protected voidrowProcessed(java.util.Map<java.lang.Class<?>,java.lang.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
-
-
-
-
Constructor Detail
-
AbstractMultiBeanListProcessor
public AbstractMultiBeanListProcessor(int expectedBeanCount, java.lang.Class... beanTypes)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 outputListreturned bygetBeans()beanTypes- the classes with their attributes mapped to fields of records parsed by anAbstractParseror written by anAbstractWriter.
-
AbstractMultiBeanListProcessor
public AbstractMultiBeanListProcessor(java.lang.Class... beanTypes)
Creates a processor for java beans of multiple types- Parameters:
beanTypes- the classes with their attributes mapped to fields of records parsed by anAbstractParseror written by anAbstractWriter.
-
-
Method Detail
-
processStarted
public final void processStarted(C context)
Description copied from interface:ProcessorThis method will by invoked by the parser once, when it is ready to start processing the input.- Specified by:
processStartedin interfaceProcessor<C extends Context>- Overrides:
processStartedin classAbstractMultiBeanRowProcessor<C extends Context>- Parameters:
context- A contextual object with information and controls over the current state of the parsing process
-
rowProcessed
protected final void rowProcessed(java.util.Map<java.lang.Class<?>,java.lang.Object> row, C context)Description copied from class:AbstractMultiBeanRowProcessorInvoked by the processor after all beans of a valid record have been processed.- Specified by:
rowProcessedin 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
public final void processEnded(C context)
Description copied from interface:ProcessorThis 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:
processEndedin interfaceProcessor<C extends Context>- Overrides:
processEndedin classAbstractMultiBeanRowProcessor<C extends Context>- Parameters:
context- A contextual object with information and controls over the state of the parsing process
-
getHeaders
public final java.lang.String[] 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
public <T> java.util.List<T> getBeans(java.lang.Class<T> beanType)
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
public java.util.Map<java.lang.Class<?>,java.util.List<?>> getBeans()
Returns a map of all beans processed from the input.- Returns:
- all beans processed from the input.
-
-