1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.rat.analysis.matchers;
20
21 import org.apache.commons.lang3.StringUtils;
22 import org.apache.rat.analysis.IHeaders;
23 import org.apache.rat.config.parameters.ComponentType;
24 import org.apache.rat.config.parameters.ConfigComponent;
25
26 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
27
28
29
30
31 @ConfigComponent(type = ComponentType.MATCHER, name = "text", desc = "Matches the enclosed text")
32 public class SimpleTextMatcher extends AbstractHeaderMatcher {
33
34
35
36 @ConfigComponent(type = ComponentType.PARAMETER, name = "simpleText", desc = "The text to match", required = true)
37 private final String simpleText;
38
39
40
41
42
43
44
45 public SimpleTextMatcher(final String simpleText) {
46 this(null, simpleText);
47 }
48
49
50 @SuppressFBWarnings("FI_USELESS")
51 @Override
52 protected final void finalize() throws Throwable {
53
54 super.finalize();
55 }
56
57
58
59
60
61
62
63 public SimpleTextMatcher(final String id, final String simpleText) {
64 super(id);
65 if (StringUtils.isBlank(simpleText)) {
66 throw new IllegalArgumentException("Simple text may not be null, empty or blank");
67 }
68 this.simpleText = simpleText;
69 }
70
71 public String getSimpleText() {
72 return this.simpleText;
73 }
74
75 @Override
76 public boolean matches(final IHeaders headers) {
77 return headers.raw().contains(simpleText);
78 }
79 }