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 public class AnyCharacterPatternConstraint extends ValidCharactersPatternConstraint {
25 protected boolean allowWhitespace = false;
26 protected boolean omitNewline = false;
27
28
29
30
31 public boolean getAllowWhitespace() {
32 return allowWhitespace;
33 }
34
35
36
37
38 public void setAllowWhitespace(boolean allowWhitespace) {
39 this.allowWhitespace = allowWhitespace;
40 }
41
42
43
44
45 protected String getRegexString() {
46 StringBuffer regexString = new StringBuffer("[");
47
48 regexString.append("\\x21-\\x7E");
49 if (allowWhitespace) {
50 regexString.append("\\t\\v\\040");
51 if (!omitNewline) {
52 regexString.append("\\f\\r\\n");
53 }
54 }
55
56 regexString.append("]");
57
58 return regexString.toString();
59 }
60
61
62
63
64 @Override
65 public String getLabelKey() {
66 String labelKey = super.getLabelKey();
67 if (StringUtils.isNotEmpty(labelKey)) {
68 return labelKey;
69 }
70 if (!allowWhitespace) {
71 return UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "noWhitespace";
72 } else {
73 return UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "anyCharacterPattern";
74 }
75 }
76
77 public boolean isOmitNewline() {
78 return omitNewline;
79 }
80
81
82
83
84
85
86
87 public void setOmitNewline(boolean omitNewline) {
88 this.omitNewline = omitNewline;
89 }
90 }