1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.codelibs.fess.es.config.exentity;
17
18 import java.util.regex.Matcher;
19 import java.util.regex.Pattern;
20
21 import org.codelibs.core.lang.StringUtil;
22 import org.codelibs.fess.es.config.bsentity.BsPathMapping;
23
24
25
26
27 public class PathMapping extends BsPathMapping {
28
29 private static final long serialVersionUID = 1L;
30
31 private Pattern regexPattern;
32
33 private Pattern userAgentPattern;
34
35 public String getId() {
36 return asDocMeta().id();
37 }
38
39 public void setId(final String id) {
40 asDocMeta().id(id);
41 }
42
43 public Long getVersionNo() {
44 return asDocMeta().version();
45 }
46
47 public void setVersionNo(final Long version) {
48 asDocMeta().version(version);
49 }
50
51 public Matcher getMatcher(final CharSequence input) {
52 if (regexPattern == null) {
53 regexPattern = Pattern.compile(getRegex());
54 }
55 return regexPattern.matcher(input);
56 }
57
58 public boolean hasUAMathcer() {
59 return StringUtil.isNotBlank(getUserAgent());
60 }
61
62 public Matcher getUAMatcher(final CharSequence input) {
63 if (!hasUAMathcer()) {
64 return null;
65 }
66
67 if (userAgentPattern == null) {
68 userAgentPattern = Pattern.compile(getUserAgent());
69 }
70 return userAgentPattern.matcher(input);
71 }
72
73 @Override
74 public String toString() {
75 return "PathMapping [regexPattern=" + regexPattern + ", createdBy=" + createdBy + ", createdTime=" + createdTime + ", processType="
76 + processType + ", regex=" + regex + ", replacement=" + replacement + ", sortOrder=" + sortOrder + ", userAgent="
77 + userAgent + ", updatedBy=" + updatedBy + ", updatedTime=" + updatedTime + ", docMeta=" + docMeta + "]";
78 }
79 }