1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.rat.analysis;
20
21 import java.io.IOException;
22 import java.io.Reader;
23
24 import org.apache.rat.api.Document;
25 import org.apache.rat.document.IDocumentAnalyser;
26 import org.apache.rat.document.RatDocumentAnalysisException;
27 import org.apache.rat.license.ILicense;
28 import org.apache.rat.utils.Log;
29
30 import static java.lang.String.format;
31
32
33
34
35 class DocumentHeaderAnalyser implements IDocumentAnalyser {
36
37
38
39
40 private final ILicense license;
41
42 private final Log log;
43
44
45
46
47
48
49 public DocumentHeaderAnalyser(final Log log, final ILicense license) {
50 super();
51 this.license = license;
52 this.log = log;
53 }
54
55 @Override
56 public void analyse(Document document) throws RatDocumentAnalysisException {
57 try (Reader reader = document.reader()) {
58 log.debug(format("Processing: %s", document));
59 HeaderCheckWorker worker = new HeaderCheckWorker(reader, license, document);
60 worker.read();
61 } catch (IOException e) {
62 throw new RatDocumentAnalysisException("Cannot read header", e);
63 } catch (RatHeaderAnalysisException e) {
64 throw new RatDocumentAnalysisException("Cannot analyse header", e);
65 }
66 }
67
68 }