Interface Processor<T extends Context>
-
- All Known Subinterfaces:
RowProcessor
- All Known Implementing Classes:
AbstractBatchedColumnProcessor
,AbstractBatchedObjectColumnProcessor
,AbstractBeanListProcessor
,AbstractBeanProcessor
,AbstractColumnProcessor
,AbstractConcurrentProcessor
,AbstractInputValueSwitch
,AbstractListProcessor
,AbstractMasterDetailListProcessor
,AbstractMasterDetailProcessor
,AbstractMultiBeanListProcessor
,AbstractMultiBeanProcessor
,AbstractMultiBeanRowProcessor
,AbstractObjectColumnProcessor
,AbstractObjectListProcessor
,AbstractObjectProcessor
,AbstractProcessor
,AbstractProcessorSwitch
,AbstractRowProcessor
,BatchedColumnProcessor
,BatchedObjectColumnProcessor
,BeanListProcessor
,BeanProcessor
,ColumnProcessor
,CompositeProcessor
,CompositeRowProcessor
,ConcurrentRowProcessor
,InputValueSwitch
,MasterDetailListProcessor
,MasterDetailProcessor
,MultiBeanListProcessor
,MultiBeanProcessor
,MultiBeanRowProcessor
,NoopProcessor
,NoopRowProcessor
,ObjectColumnProcessor
,ObjectRowListProcessor
,ObjectRowProcessor
,RowListProcessor
,RowProcessorSwitch
public interface Processor<T extends Context>
The essential callback interface to handle records parsed by any parser that extendsAbstractParser
.When parsing an input, univocity-parsers will obtain the RowProcessor from
CommonParserSettings.getRowProcessor()
, and delegate each parsed row torowProcessed(String[], Context)
.Before parsing the first row, the parser will invoke the
processStarted(Context)
method. By this time the input buffer will be already loaded and ready to be consumed.After parsing the last row, all resources are closed and the processing stops. Only after the
processEnded(Context)
is called so you can perform any additional housekeeping you might need.More control and information over the parsing process are provided by the
Context
object.univocity-parsers provides many useful default implementations of this interface in the package
com.univocity.parsers.common.processor
, namely:RowListProcessor
: convenience class for storing the processed rows into a list.ObjectRowProcessor
: used for processing rows and executing conversions of parsed values to objects using instances ofConversion
ObjectRowListProcessor
: convenience class for rows of converted objects usingObjectRowProcessor
into a list.AbstractMasterDetailProcessor
: used for reading inputs where records are organized in a master-detail fashion (with a master element that contains a list of associated elements)AbstractMasterDetailListProcessor
: convenience class for storingMasterDetailRecord
created by instances created byAbstractMasterDetailProcessor
into a listAbstractBeanProcessor
: used for automatically create and populate javabeans annotated with the annotations provided in packagecom.univocity.parsers.annotations
AbstractBeanListProcessor
: convenience class for storing all javabeans created byAbstractBeanProcessor
into a list
- See Also:
AbstractParser
,CommonParserSettings
,ParsingContext
,Context
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
processEnded(T context)
This method will by invoked by the parser once, after the parsing process stopped and all resources were closed.void
processStarted(T 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, T context)
Invoked by the parser after all values of a valid record have been processed.
-
-
-
Method Detail
-
processStarted
void processStarted(T context)
This method will by invoked by the parser once, when it is ready to start processing the input.- Parameters:
context
- A contextual object with information and controls over the current state of the parsing process
-
rowProcessed
void rowProcessed(java.lang.String[] row, T context)
Invoked by the parser after all values of a valid record have been processed.- 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
-
processEnded
void processEnded(T context)
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()
.- Parameters:
context
- A contextual object with information and controls over the state of the parsing process
-
-