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.datadictionary.parse.BeanTag;
20 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
21 import org.kuali.rice.krad.datadictionary.parse.BeanTags;
22 import org.kuali.rice.krad.uif.UifConstants;
23
24
25
26
27
28
29 @BeanTags({@BeanTag(name = "alphaPatternConstraint-bean", parent = "AlphaPatternConstraint"),
30 @BeanTag(name = "alphaWithBasicPunc-bean", parent = "AlphaWithBasicPunc")})
31 public class AlphaPatternConstraint extends AllowCharacterConstraint {
32 protected boolean lowerCase = false;
33 protected boolean upperCase = false;
34
35
36
37
38 protected String getRegexString() {
39 StringBuilder regexString = new StringBuilder("[A-Za-z");
40
41
42
43 if (lowerCase) {
44 regexString = new StringBuilder("[a-z");
45 } else if (upperCase) {
46 regexString = new StringBuilder("[A-Z");
47 }
48 regexString.append(this.getAllowedCharacterRegex());
49 regexString.append("]");
50
51 return regexString.toString();
52 }
53
54
55
56
57
58
59
60 @Override
61 public String getMessageKey() {
62 if (StringUtils.isEmpty(messageKey)) {
63 StringBuilder key = new StringBuilder("");
64 if (lowerCase) {
65 return (UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "alphaPatternLowerCase");
66 } else if (upperCase) {
67 return (UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "alphaPatternUpperCase");
68 } else {
69 return (UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "alphaPattern");
70 }
71 }
72
73 return messageKey;
74 }
75
76
77
78
79 @BeanTagAttribute(name = "lowerCase")
80 public boolean isLowerCase() {
81 return this.lowerCase;
82 }
83
84
85
86
87
88
89
90 public void setLowerCase(boolean lowerCase) {
91 this.lowerCase = lowerCase;
92 }
93
94 @BeanTagAttribute(name = "upperCase")
95 public boolean isUpperCase() {
96 return upperCase;
97 }
98
99
100
101
102
103
104
105 public void setUpperCase(boolean upperCase) {
106 this.upperCase = upperCase;
107 }
108
109 }