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
27
28
29 @ConfigComponent(type = ComponentType.MATCHER, name = "text", desc = "Matches the enclosed text")
30 public class SimpleTextMatcher extends AbstractHeaderMatcher {
31
32
33
34 @ConfigComponent(type = ComponentType.PARAMETER, name = "simpleText", desc = "The text to match", required = true)
35 private final String simpleText;
36
37
38
39
40
41
42
43 public SimpleTextMatcher(final String simpleText) {
44 this(null, simpleText);
45 }
46
47
48
49
50
51
52
53 public SimpleTextMatcher(final String id, final String simpleText) {
54 super(id);
55 if (StringUtils.isBlank(simpleText)) {
56 throw new IllegalArgumentException("Simple text may not be null, empty or blank");
57 }
58 this.simpleText = simpleText;
59 }
60
61 public String getSimpleText() {
62 return this.simpleText;
63 }
64
65 @Override
66 public boolean matches(final IHeaders headers) {
67 return headers.raw().contains(simpleText);
68 }
69 }