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
28 public class DocumentHeaderAnalyser implements IDocumentAnalyser {
29
30 private final IHeaderMatcher matcher;
31
32 public DocumentHeaderAnalyser(final IHeaderMatcher matcher) {
33 super();
34 this.matcher = matcher;
35 }
36
37 public void analyse(Document document) throws RatDocumentAnalysisException {
38 Reader reader = null;
39 try {
40 reader = document.reader();
41
42 HeaderCheckWorker worker = new HeaderCheckWorker(reader, matcher, document);
43 worker.read();
44 } catch (IOException e) {
45 throw new RatDocumentAnalysisException("Cannot read header", e);
46 } catch (RatHeaderAnalysisException e) {
47 throw new RatDocumentAnalysisException("Cannot analyse header", e);
48 } finally {
49 if (reader != null) {
50 try {
51 reader.close();
52 } catch (IOException e) {
53
54 }
55 }
56 }
57 }
58
59 }