001package com.credibledoc.substitution.reporting.reportdocument; 002 003import com.credibledoc.enricher.line.LineProcessor; 004import com.credibledoc.substitution.reporting.visualizer.VisualizerService; 005 006import java.util.ArrayList; 007import java.util.List; 008 009/** 010 * A stateful class. Contains {@link #reportDocuments} and {@link #reportDocumentsForAddition}. 011 * 012 * @author Kyrylo Semenko 013 */ 014public class ReportDocumentRepository { 015 016 /** 017 * All {@link ReportDocument}s that will be completed during parsing. 018 * {@link VisualizerService} will read line by 019 * line source files and for each line will try to apply all 020 * {@link LineProcessor}s related with all reportDocuments. 021 * If the current log line is applicable to the 022 * current {@link ReportDocument}, it can be transformed and appended 023 * to the {@link ReportDocument#getCacheLines()} or / and returned from the 024 * current {@link LineProcessor}. Returned 025 * transformed line will be written to a report file immediately. 026 */ 027 private ReportDocumentList<ReportDocument> reportDocuments = new ReportDocumentList<>(); 028 029 /** 030 * During parsing of files we can add {@link ReportDocument}s to the 031 * {@link ReportDocument}s list. We can`t add them to the list directly, 032 * because {@link java.util.ConcurrentModificationException} is throwing. 033 * So wee need to add them tho this reportDocumentsForAddition 034 * first, and merge this list to the {@link ReportDocument}s after the 035 * current log line has been processed by all items from the 036 * {@link ReportDocument}s list. See the 037 * {@link VisualizerService} createReports method. 038 */ 039 private List<ReportDocument> reportDocumentsForAddition = new ArrayList<>(); 040 041 /** 042 * @return The {@link #reportDocuments} field value. 043 */ 044 public ReportDocumentList<ReportDocument> getReportDocuments() { 045 return reportDocuments; 046 } 047 048 /** 049 * @param reportDocuments see the {@link #reportDocuments} field 050 */ 051 public void setReportDocuments(ReportDocumentList<ReportDocument> reportDocuments) { 052 this.reportDocuments = reportDocuments; 053 } 054 055 /** 056 * @return The {@link #reportDocumentsForAddition} field value. 057 */ 058 public List<ReportDocument> getReportDocumentsForAddition() { 059 return reportDocumentsForAddition; 060 } 061 062 /** 063 * @param reportDocumentsForAddition see the {@link #reportDocumentsForAddition} field 064 */ 065 public void setReportDocumentsForAddition(List<ReportDocument> reportDocumentsForAddition) { 066 this.reportDocumentsForAddition = reportDocumentsForAddition; 067 } 068}