Class AbstractMasterDetailListProcessor<T extends Context>

  • 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&lt;MasterDetailRecord&gt; rows = masterRowProcessor.getRecords();
     

    See Also:
    AbstractMasterDetailProcessor, Processor, AbstractParser
    • Field Detail

      • headers

        private java.lang.String[] headers
    • Constructor Detail

      • 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 | 100
         

        detailProcessor - the ObjectRowListProcessor that processes detail rows.
      • AbstractMasterDetailListProcessor

        public AbstractMasterDetailListProcessor​(AbstractObjectListProcessor detailProcessor)
        Creates a MasterDetailListProcessor assuming master records are positioned above its detail records in the input.
        Parameters:
        detailProcessor - the ObjectRowListProcessor that processes detail rows.
    • Method Detail

      • processEnded

        public void processEnded​(T 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 interface Processor<T extends Context>
        Overrides:
        processEnded in class AbstractMasterDetailProcessor<T extends Context>
        Parameters:
        context - A contextual object with information and controls over the state of the parsing process
      • getRecords

        public java.util.List<MasterDetailRecord> 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

        public java.lang.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:
        the headers of all records parsed.