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 java.util.List;
22
23 import org.apache.rat.api.Document;
24 import org.apache.rat.api.RatException;
25 import org.apache.rat.document.IDocumentAnalyser;
26 import org.apache.rat.document.RatDocumentAnalysisException;
27 import org.apache.rat.report.RatReport;
28
29
30 public class ClaimReporterMultiplexer implements RatReport {
31 private final IDocumentAnalyser analyser;
32 private final List reporters;
33
34 public ClaimReporterMultiplexer(final IDocumentAnalyser pAnalyser, final List 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 final int length = reporters.size();
48 for (int i=0; i<length; i++) {
49 final RatReport report = (RatReport) reporters.get(i);
50 report.report(document);
51 }
52 }
53
54 public void startReport() throws RatException {
55 final int length = reporters.size();
56 for (int i=0; i<length; i++) {
57 final RatReport report = (RatReport) reporters.get(i);
58 report.startReport();
59 }
60 }
61
62 public void endReport() throws RatException {
63 final int length = reporters.size();
64 for (int i=0; i<length; i++) {
65 final RatReport report = (RatReport) reporters.get(i);
66 report.endReport();
67 }
68 }
69 }