##### Coverage Report - org.apache.any23.ExtractionReport

Classes in this File | Line Coverage | Branch Coverage | Complexity
ExtractionReport |
0% | 0/17
0% | 0/10
| 2.0;2

1 |  |
     /*
2 |  |
      * Licensed to the Apache Software Foundation (ASF) under one or more
3 |  |
      * contributor license agreements.  See the NOTICE file distributed with
4 |  |
      * this work for additional information regarding copyright ownership.
5 |  |
      * The ASF licenses this file to You under the Apache License, Version 2.0
6 |  |
      * (the "License"); you may not use this file except in compliance with
7 |  |
      * the License.  You may obtain a copy of the License at
8 |  |
      *
9 |  |
      *  http://www.apache.org/licenses/LICENSE-2.0
10 |  |
      *
11 |  |
      * Unless required by applicable law or agreed to in writing, software
12 |  |
      * distributed under the License is distributed on an "AS IS" BASIS,
13 |  |
      * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 |  |
      * See the License for the specific language governing permissions and
15 |  |
      * limitations under the License.
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 |  |
      * This class contains some statistics and general information about
32 |  |
      * an extraction.
33 |  |
      *
34 |  |
      * @see Any23
35 |  |
      * @author Michele Mostarda (mostarda@fbk.eu)
36 |  |
      * @author Davide Palmisano (palmisano@fbk.eu)
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 |  |
             // if(detectedMimeType == null) throw new NullPointerException("detected mime type cannot be null.");
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 |  |
          * @return <code>true</code> if the extraction has activated
71 |  |
          *         at least an extractor, <code>false</code> otherwise.
72 |  |
          */
73 |  |
         public boolean hasMatchingExtractors() {
74 | 0 |
             return matchingExtractors.size() > 0;
75 |  |
         }
76 |  |
77 |  |
         /**
78 |  |
          * @return the (unmodifiable) list of matching extractors.
79 |  |
          */
80 |  |
         public List<Extractor> getMatchingExtractors() {
81 | 0 |
             return matchingExtractors;
82 |  |
         }
83 |  |
84 |  |
         /**
85 |  |
          * @return the detected encoding for the source stream.
86 |  |
          */
87 |  |
         public String getEncoding() {
88 | 0 |
             return encoding;
89 |  |
         }
90 |  |
91 |  |
         /**
92 |  |
          * @return the tetected mimetype for the input stream.
93 |  |
          */
94 |  |
         public String getDetectedMimeType() {
95 | 0 |
             return detectedMimeType;
96 |  |
         }
97 |  |
98 |  |
         /**
99 |  |
          * @return the validation report applied to the processed document.
100 |  |
          */
101 |  |
         public ValidationReport getValidationReport() {
102 | 0 |
             return validationReport;
103 |  |
         }
104 |  |
105 |  |
         /**
106 |  |
          * @param extractorName name of the extractor.
107 |  |
          * @return the (unmodifiable) map of errors per extractor.
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 |  |
     }