Class AbstractBeanProcessor<T,C extends Context>
- java.lang.Object
-
- com.univocity.parsers.common.DefaultConversionProcessor
-
- com.univocity.parsers.common.processor.core.BeanConversionProcessor<T>
-
- com.univocity.parsers.common.processor.core.AbstractBeanProcessor<T,C>
-
- Type Parameters:
T
- the annotated class type.
- All Implemented Interfaces:
ConversionProcessor
,Processor<C>
- Direct Known Subclasses:
AbstractBeanListProcessor
,BeanProcessor
public abstract class AbstractBeanProcessor<T,C extends Context> extends BeanConversionProcessor<T> implements Processor<C>
AProcessor
implementation for converting rows extracted from any implementation ofAbstractParser
into java objects.The class type of the object must contain the annotations provided in
com.univocity.parsers.annotations
.For each row processed, a java bean instance of a given class will be created with its fields populated.
This instance will then be sent to the
beanProcessed(Object, Context)
method, where the user can access it.- See Also:
AbstractParser
,Processor
-
-
Field Summary
-
Fields inherited from class com.univocity.parsers.common.processor.core.BeanConversionProcessor
beanClass, constructor, initialized, methodFilter, parsedFields, strictHeaderValidationEnabled, transformer
-
Fields inherited from class com.univocity.parsers.common.DefaultConversionProcessor
conversions
-
-
Constructor Summary
Constructors Constructor Description AbstractBeanProcessor(java.lang.Class<T> beanType, MethodFilter methodFilter)
Creates a processor for java beans of a given type.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
beanProcessed(T bean, C context)
Invoked by the processor after all values of a valid record have been processed and converted into a java object.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.void
rowProcessed(java.lang.String[] row, C context)
Converts a parsed row to a java object-
Methods inherited from class com.univocity.parsers.common.processor.core.BeanConversionProcessor
addConversion, cloneConversions, createBean, createNestedProcessor, describeField, getBeanClass, getColumnMapper, getNestedAttributes, initialize, initialize, initialize, isStrictHeaderValidationEnabled, mapValuesToFields, processField, processField, processNestedAttributes, reverseConversions, setColumnMapper, setStrictHeaderValidationEnabled, validateMappings
-
Methods inherited from class com.univocity.parsers.common.DefaultConversionProcessor
applyConversions, convertAll, convertFields, convertIndexes, convertType, handleConversionError, initializeConversions, reverseConversions, toDataProcessingException
-
-
-
-
Constructor Detail
-
AbstractBeanProcessor
public AbstractBeanProcessor(java.lang.Class<T> beanType, MethodFilter methodFilter)
Creates a processor for java beans of a given type.- Parameters:
beanType
- the class with its attributes mapped to fields of records parsed by anAbstractParser
or written by anAbstractWriter
.methodFilter
- filter to apply over annotated methods when the processor is reading data from beans (to write values to an output) or writing values into beans (when parsing). It is used to choose either a "get" or a "set" method annotated withParsed
, when both methods target the same field.
-
-
Method Detail
-
rowProcessed
public final void rowProcessed(java.lang.String[] row, C context)
Converts a parsed row to a java object- Specified by:
rowProcessed
in interfaceProcessor<T>
- Parameters:
row
- the data extracted by the parser for an individual record. Note that:- it will never by null.
- it will never be empty unless explicitly configured using
CommonSettings.setSkipEmptyLines(boolean)
- it won't contain lines identified by the parser as comments. To disable comment processing set
Format.setComment(char)
to '\0'
context
- A contextual object with information and controls over the current state of the parsing process
-
beanProcessed
public abstract void beanProcessed(T bean, C context)
Invoked by the processor after all values of a valid record have been processed and converted into a java object.- Parameters:
bean
- java object created with the information extracted by the parser for an individual record.context
- A contextual object with information and controls over the current state of the parsing process
-
processStarted
public void processStarted(C context)
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<T>
- Parameters:
context
- A contextual object with information and controls over the current state of the parsing process
-
processEnded
public void processEnded(C context)
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<T>
- Parameters:
context
- A contextual object with information and controls over the state of the parsing process
-
-