1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.any23;
19
20 import org.apache.any23.extractor.IssueReport;
21 import org.apache.any23.extractor.Extractor;
22 import org.apache.any23.validator.ValidationReport;
23
24 import java.util.Collection;
25 import java.util.Collections;
26 import java.util.List;
27 import java.util.Map;
28
29
30
31
32
33
34
35
36
37 public class ExtractionReport {
38
39 private final List<Extractor> matchingExtractors;
40
41 private final String encoding;
42
43 private final String detectedMimeType;
44
45 private final ValidationReport validationReport;
46
47 private final Map<String, Collection<IssueReport.Issue>> extractorIssues;
48
49 public ExtractionReport(final List<Extractor> matchingExtractors, String encoding, String detectedMimeType,
50 ValidationReport validationReport, Map<String, Collection<IssueReport.Issue>> extractorIssues) {
51 if (matchingExtractors == null)
52 throw new NullPointerException("list of matching extractors cannot be null.");
53 if (encoding == null)
54 throw new NullPointerException("encoding cannot be null.");
55
56 if (validationReport == null)
57 throw new NullPointerException("validation report cannot be null.");
58
59 this.matchingExtractors = Collections.unmodifiableList(matchingExtractors);
60 this.encoding = encoding;
61 this.detectedMimeType = detectedMimeType;
62 this.validationReport = validationReport;
63 this.extractorIssues = Collections.unmodifiableMap(extractorIssues);
64 }
65
66
67
68
69 public boolean hasMatchingExtractors() {
70 return matchingExtractors.size() > 0;
71 }
72
73
74
75
76 public List<Extractor> getMatchingExtractors() {
77 return matchingExtractors;
78 }
79
80
81
82
83 public String getEncoding() {
84 return encoding;
85 }
86
87
88
89
90 public String getDetectedMimeType() {
91 return detectedMimeType;
92 }
93
94
95
96
97 public ValidationReport getValidationReport() {
98 return validationReport;
99 }
100
101
102
103
104
105
106
107 public Collection<IssueReport.Issue> getExtractorIssues(String extractorName) {
108 final Collection<IssueReport.Issue> errors = extractorIssues.get(extractorName);
109 return errors == null ? Collections.<IssueReport.Issue> emptyList()
110 : Collections.unmodifiableCollection(errors);
111 }
112
113 }