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.ErrorReporter; |
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 | |
|
38 | |
public class ExtractionReport { |
39 | |
|
40 | |
private final List<Extractor> matchingExtractors; |
41 | |
|
42 | |
private final String encoding; |
43 | |
|
44 | |
private final String detectedMimeType; |
45 | |
|
46 | |
private final ValidationReport validationReport; |
47 | |
|
48 | |
private final Map<String,Collection<ErrorReporter.Error>> extractorErrors; |
49 | |
|
50 | |
public ExtractionReport( |
51 | |
final List<Extractor> matchingExtractors, |
52 | |
String encoding, |
53 | |
String detectedMimeType, |
54 | |
ValidationReport validationReport, |
55 | |
Map<String,Collection<ErrorReporter.Error>> extractorErrors |
56 | 0 | ) { |
57 | 0 | if(matchingExtractors == null) throw new NullPointerException("list of matching extractors cannot be null."); |
58 | 0 | if(encoding == null) throw new NullPointerException("encoding cannot be null."); |
59 | |
|
60 | 0 | if(validationReport == null) throw new NullPointerException("validation report cannot be null."); |
61 | |
|
62 | 0 | this.matchingExtractors = Collections.unmodifiableList(matchingExtractors); |
63 | 0 | this.encoding = encoding; |
64 | 0 | this.detectedMimeType = detectedMimeType; |
65 | 0 | this.validationReport = validationReport; |
66 | 0 | this.extractorErrors = Collections.unmodifiableMap(extractorErrors); |
67 | 0 | } |
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
public boolean hasMatchingExtractors() { |
74 | 0 | return matchingExtractors.size() > 0; |
75 | |
} |
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
public List<Extractor> getMatchingExtractors() { |
81 | 0 | return matchingExtractors; |
82 | |
} |
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
public String getEncoding() { |
88 | 0 | return encoding; |
89 | |
} |
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
public String getDetectedMimeType() { |
95 | 0 | return detectedMimeType; |
96 | |
} |
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
public ValidationReport getValidationReport() { |
102 | 0 | return validationReport; |
103 | |
} |
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
public Collection<ErrorReporter.Error> getExtractorErrors(String extractorName) { |
110 | 0 | final Collection<ErrorReporter.Error> errors = extractorErrors.get(extractorName); |
111 | 0 | return errors == null |
112 | |
? |
113 | |
Collections.<ErrorReporter.Error>emptyList() |
114 | |
: |
115 | |
Collections.unmodifiableCollection(errors); |
116 | |
} |
117 | |
|
118 | |
} |