1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.rat.report.claim.util;
20
21 import org.apache.rat.api.Document;
22 import org.apache.rat.api.RatException;
23 import org.apache.rat.document.IDocumentAnalyser;
24 import org.apache.rat.document.RatDocumentAnalysisException;
25 import org.apache.rat.report.RatReport;
26
27 import java.util.List;
28
29
30 public class ClaimReporterMultiplexer implements RatReport {
31 private final IDocumentAnalyser analyser;
32 private final List<? extends RatReport> reporters;
33
34 public ClaimReporterMultiplexer(final IDocumentAnalyser pAnalyser, final List<? extends RatReport> reporters) {
35 analyser = pAnalyser;
36 this.reporters = reporters;
37 }
38
39 public void report(Document document) throws RatException {
40 if (analyser != null) {
41 try {
42 analyser.analyse(document);
43 } catch (RatDocumentAnalysisException e) {
44 throw new RatException(e.getMessage(), e);
45 }
46 }
47 for (RatReport report : reporters) {
48 report.report(document);
49 }
50 }
51
52 public void startReport() throws RatException {
53 for (RatReport report : reporters) {
54 report.startReport();
55 }
56 }
57
58 public void endReport() throws RatException {
59 for (RatReport report : reporters) {
60 report.endReport();
61 }
62 }
63 }