1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.datadictionary.validation.constraint;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.krad.uif.UifConstants;
20
21
22
23
24
25
26
27 public class AlphaPatternConstraint extends AllowCharacterConstraint {
28 protected boolean lowerCase = false;
29 protected boolean upperCase = false;
30
31
32
33
34 protected String getRegexString() {
35 StringBuilder regexString = new StringBuilder("[A-Za-z");
36
37
38
39 if (lowerCase) {
40 regexString = new StringBuilder("[a-z");
41 }
42 else if(upperCase){
43 regexString = new StringBuilder("[A-Z");
44 }
45 regexString.append(this.getAllowedCharacterRegex());
46 regexString.append("]");
47
48 return regexString.toString();
49 }
50
51
52
53
54
55
56
57 @Override
58 public String getLabelKey() {
59 if (StringUtils.isEmpty(labelKey)) {
60 StringBuilder key = new StringBuilder("");
61 if (lowerCase) {
62 return (UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "alphaPatternLowerCase");
63 } else if(upperCase){
64 return (UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "alphaPatternUpperCase");
65 }
66 else{
67 return (UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "alphaPattern");
68 }
69 }
70 return labelKey;
71 }
72
73
74
75
76 public boolean isLowerCase() {
77 return this.lowerCase;
78 }
79
80
81
82
83
84
85 public void setLowerCase(boolean lowerCase) {
86 this.lowerCase = lowerCase;
87 }
88
89 public boolean isUpperCase() {
90 return upperCase;
91 }
92
93
94
95
96
97
98 public void setUpperCase(boolean upperCase) {
99 this.upperCase = upperCase;
100 }
101
102 }