Top Description Fields Constructors Methods
com.univocity.parsers.common.processor.core

public abstract Class AbstractMasterDetailListProcessor<T extends Context>

extends AbstractMasterDetailProcessor<T extends Context>
Class Inheritance
Known Direct Subclasses
com.univocity.parsers.common.processor.MasterDetailListProcessor
Imports
com.univocity.parsers.common.*, com.univocity.parsers.common.processor.*, java.util.*

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 - [email protected]
See Also
AbstractMasterDetailProcessor, Processor, AbstractParser

Field Summary

Modifier and TypeField and Description
private String[]
private final List<MasterDetailRecord>

Constructor Summary

AccessConstructor and Description
public
AbstractMasterDetailListProcessor(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

rowPlacement
,
AbstractObjectListProcessor<T extends Context>
the ObjectRowListProcessor that processes detail rows.
detailProcessor
)

Creates a MasterDetailListProcessor

public
AbstractMasterDetailListProcessor(AbstractObjectListProcessor<T extends Context>
the ObjectRowListProcessor that processes detail rows.
detailProcessor
)

Creates a MasterDetailListProcessor assuming master records are positioned above its detail records in the input.

Method Summary

Modifier and TypeMethod and Description
public String[]

Returns:

the headers of all records parsed.
getHeaders
()

Returns the record headers.

public List<MasterDetailRecord>

Returns:

the list of generated MasterDetailRecords at the end of the parsing process.
getRecords
()

Returns the list of generated MasterDetailRecords at the end of the parsing process.

protected void
masterDetailRecordProcessed(MasterDetailRecord
MasterDetailRecord generated with a set of associated records extracted by the parser
record
,
T
A contextual object with information and controls over the current state of the parsing process
context
)

Implements abstract com.univocity.parsers.common.processor.core.AbstractMasterDetailProcessor.masterDetailRecordProcessed.

Stores the generated MasterDetailRecord with the set of associated parsed records into a list.
public void
processEnded(T
A contextual object with information and controls over the state of the parsing process
context
)

Overrides com.univocity.parsers.common.processor.core.AbstractMasterDetailProcessor.processEnded.

Implements com.univocity.parsers.common.processor.core.Processor.processEnded.

This method will by invoked by the parser once, after the parsing process stopped and all resources were closed.
Inherited from com.univocity.parsers.common.processor.core.AbstractMasterDetailProcessor:
isMasterRecordprocessStartedrowProcessedrowProcessed

Field Detail

headersback to summary
private String[] headers
recordsback to summary
private final List<MasterDetailRecord> records

Constructor Detail

AbstractMasterDetailListProcessorback to summary
public AbstractMasterDetailListProcessor(RowPlacement rowPlacement, AbstractObjectListProcessor<T extends Context> detailProcessor)

Creates a MasterDetailListProcessor

Parameters
rowPlacement: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:AbstractObjectListProcessor<T extends Context>

the ObjectRowListProcessor that processes detail rows.

AbstractMasterDetailListProcessorback to summary
public AbstractMasterDetailListProcessor(AbstractObjectListProcessor<T extends Context> detailProcessor)

Creates a MasterDetailListProcessor assuming master records are positioned above its detail records in the input.

Parameters
detailProcessor:AbstractObjectListProcessor<T extends Context>

the ObjectRowListProcessor that processes detail rows.

Method Detail

getHeadersback to summary
public String[] getHeaders()

Returns the record headers. This can be either the headers defined in CommonSettings#getHeaders() or the headers parsed in the file when CommonSettings#getHeaders() equals true

Returns:String[]

the headers of all records parsed.

getRecordsback to summary
public List<MasterDetailRecord> getRecords()

Returns the list of generated MasterDetailRecords at the end of the parsing process.

Returns:List<MasterDetailRecord>

the list of generated MasterDetailRecords at the end of the parsing process.

masterDetailRecordProcessedback to summary
protected void masterDetailRecordProcessed(MasterDetailRecord record, T context)

Implements abstract com.univocity.parsers.common.processor.core.AbstractMasterDetailProcessor.masterDetailRecordProcessed.

Stores the generated MasterDetailRecord with the set of associated parsed records into a list.

Parameters
record:MasterDetailRecord

MasterDetailRecord generated with a set of associated records extracted by the parser

context:T

A contextual object with information and controls over the current state of the parsing process

Annotations
@Override
See Also
MasterDetailRecord
processEndedback to summary
public void processEnded(T context)

Overrides com.univocity.parsers.common.processor.core.AbstractMasterDetailProcessor.processEnded.

Implements com.univocity.parsers.common.processor.core.Processor.processEnded.

Doc from com.univocity.parsers.common.processor.core.Processor.processEnded.

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 ParsingContext#stop().

Parameters
context:T

A contextual object with information and controls over the state of the parsing process

Annotations
@Override