Class AbstractMasterDetailListProcessor<T extends Context>
java.lang.Object
com.univocity.parsers.common.DefaultConversionProcessor
com.univocity.parsers.common.processor.core.AbstractObjectProcessor<T>
com.univocity.parsers.common.processor.core.AbstractMasterDetailProcessor<T>
com.univocity.parsers.common.processor.core.AbstractMasterDetailListProcessor<T>
- All Implemented Interfaces:
ConversionProcessor,Processor<T>
- Direct Known Subclasses:
MasterDetailListProcessor
public abstract class AbstractMasterDetailListProcessor<T extends Context>
extends AbstractMasterDetailProcessor<T>
A convenience
Processor implementation for storing all MasterDetailRecord generated form the parsed input into a list.
A typical use case of this class will be:
ObjectRowListProcessor detailProcessor = new ObjectRowListProcessor(); MasterDetailListProcessor masterRowProcessor = new MasterDetailListProcessor(detailProcessor) { protected boolean isMasterRecord(String[] row, ParsingContext context) { return "Total".equals(row[0]); } }; parserSettings.setRowProcessor(masterRowProcessor); List<MasterDetailRecord> rows = masterRowProcessor.getRecords();
- Author:
- Univocity Software Pty Ltd - parsers@univocity.com
- See Also:
-
Field Summary
Fields inherited from class com.univocity.parsers.common.DefaultConversionProcessor
conversions -
Constructor Summary
ConstructorsConstructorDescriptionAbstractMasterDetailListProcessor(AbstractObjectListProcessor detailProcessor) Creates a MasterDetailListProcessor assuming master records are positioned above its detail records in the input.AbstractMasterDetailListProcessor(RowPlacement rowPlacement, AbstractObjectListProcessor detailProcessor) Creates a MasterDetailListProcessor -
Method Summary
Modifier and TypeMethodDescriptionString[]Returns the record headers.Returns the list of generated MasterDetailRecords at the end of the parsing process.protected voidmasterDetailRecordProcessed(MasterDetailRecord record, T context) Stores the generatedMasterDetailRecordwith the set of associated parsed records into a list.voidprocessEnded(T context) This method will by invoked by the parser once, after the parsing process stopped and all resources were closed.Methods inherited from class com.univocity.parsers.common.processor.core.AbstractMasterDetailProcessor
isMasterRecord, processStarted, rowProcessed, rowProcessedMethods inherited from class com.univocity.parsers.common.DefaultConversionProcessor
applyConversions, convertAll, convertFields, convertIndexes, convertType, handleConversionError, initializeConversions, reverseConversions, toDataProcessingException
-
Constructor Details
-
AbstractMasterDetailListProcessor
public AbstractMasterDetailListProcessor(RowPlacement rowPlacement, AbstractObjectListProcessor detailProcessor) Creates a MasterDetailListProcessor- Parameters:
rowPlacement- indication whether the master records are placed in relation its detail records in the input.Master record (Totals) Master record (Totals) above detail records under detail records Totals | 100 Item | 60 Item | 60 Item | 40 Item | 40 Totals | 100detailProcessor- theObjectRowListProcessorthat processes detail rows.
-
AbstractMasterDetailListProcessor
Creates a MasterDetailListProcessor assuming master records are positioned above its detail records in the input.- Parameters:
detailProcessor- theObjectRowListProcessorthat processes detail rows.
-
-
Method Details
-
masterDetailRecordProcessed
Stores the generatedMasterDetailRecordwith the set of associated parsed records into a list.- Specified by:
masterDetailRecordProcessedin classAbstractMasterDetailProcessor<T extends Context>- Parameters:
record-MasterDetailRecordgenerated with a set of associated records extracted by the parsercontext- A contextual object with information and controls over the current state of the parsing process- See Also:
-
processEnded
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<T extends Context>- Overrides:
processEndedin classAbstractMasterDetailProcessor<T extends Context>- Parameters:
context- A contextual object with information and controls over the state of the parsing process
-
getRecords
Returns the list of generated MasterDetailRecords at the end of the parsing process.- Returns:
- the list of generated MasterDetailRecords at the end 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.
-