1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.datadictionary.validation.constraint;
17
18 import org.apache.commons.lang.StringUtils;
19
20
21
22
23
24
25
26 public class AlphaPatternConstraint extends ValidCharactersPatternConstraint {
27 protected boolean allowWhitespace = false;
28
29
30
31
32
33 public boolean getAllowWhitespace() {
34 return allowWhitespace;
35 }
36
37
38
39
40 public void setAllowWhitespace(boolean allowWhitespace) {
41 this.allowWhitespace = allowWhitespace;
42 }
43
44
45
46
47
48 protected String getRegexString() {
49 StringBuffer regexString = new StringBuffer("[A-Za-z");
50
51 if (allowWhitespace) {
52 regexString.append("\\s");
53 }
54 regexString.append("]");
55
56 return regexString.toString();
57 }
58
59
60
61
62
63 @Override
64 public String getLabelKey() {
65 String labelKey = super.getLabelKey();
66 if (StringUtils.isNotEmpty(labelKey)) {
67 return labelKey;
68 }
69 StringBuilder key = new StringBuilder("");
70 key.append("alphaPattern,");
71 if (getAllowWhitespace()) {
72 key.append("whitespace");
73 }
74 return key.toString();
75 }
76
77
78
79
80
81
82
83
84
85 }