public abstract class AbstractMasterDetailListProcessor<T extends Context> extends AbstractMasterDetailProcessor<T>
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();
AbstractMasterDetailProcessor
,
Processor
,
AbstractParser
Constructor and Description |
---|
AbstractMasterDetailListProcessor(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
|
Modifier and Type | Method and Description |
---|---|
String[] |
getHeaders()
Returns the record headers.
|
List<MasterDetailRecord> |
getRecords()
Returns the list of generated MasterDetailRecords at the end of the parsing process.
|
protected void |
masterDetailRecordProcessed(MasterDetailRecord record,
T context)
Stores the generated
MasterDetailRecord with the set of associated parsed records into a list. |
void |
processEnded(T context)
This method will by invoked by the parser once, after the parsing process stopped and all resources were closed.
|
isMasterRecord, processStarted, rowProcessed, rowProcessed
applyConversions, convertAll, convertFields, convertIndexes, convertType, handleConversionError, initializeConversions, reverseConversions, toDataProcessingException
public AbstractMasterDetailListProcessor(RowPlacement rowPlacement, AbstractObjectListProcessor detailProcessor)
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 | 100
detailProcessor
- the ObjectRowListProcessor
that processes detail rows.public AbstractMasterDetailListProcessor(AbstractObjectListProcessor detailProcessor)
detailProcessor
- the ObjectRowListProcessor
that processes detail rows.protected void masterDetailRecordProcessed(MasterDetailRecord record, T context)
MasterDetailRecord
with the set of associated parsed records into a list.masterDetailRecordProcessed
in class AbstractMasterDetailProcessor<T extends Context>
record
- MasterDetailRecord
generated with a set of associated records extracted by the parsercontext
- A contextual object with information and controls over the current state of the parsing processMasterDetailRecord
public void processEnded(T 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<T extends Context>
processEnded
in class AbstractMasterDetailProcessor<T extends Context>
context
- A contextual object with information and controls over the state of the parsing processpublic List<MasterDetailRecord> getRecords()
public String[] getHeaders()
CommonSettings.getHeaders()
or the headers parsed in the file when CommonSettings.getHeaders()
equals trueCopyright © 2019 uniVocity Software Pty Ltd. All rights reserved.