1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.datadictionary.validation.charlevel;
17
18 import org.kuali.rice.krad.datadictionary.exporter.ExportMap;
19 import org.kuali.rice.krad.datadictionary.validation.CharacterLevelValidationPattern;
20 import org.kuali.rice.krad.util.KRADConstants;
21
22
23
24
25
26
27
28 public class UTF8AnyCharacterValidationPattern extends CharacterLevelValidationPattern{
29
30 protected boolean allowWhitespace = false;
31
32
33
34
35
36 public boolean getAllowWhitespace() {
37 return allowWhitespace;
38 }
39
40
41
42
43 public void setAllowWhitespace(boolean allowWhitespace) {
44 this.allowWhitespace = allowWhitespace;
45 }
46
47
48
49
50
51
52 @Override
53 protected String getRegexString() {
54 StringBuffer regexString = new StringBuffer("[");
55
56 if(!allowWhitespace)
57 regexString.append("[\\\u0000-\u10FFFF&&[^\\p{Space}]]");
58
59 else{
60 regexString.append("\\\u0000-\u10FFFF");
61 }
62
63 regexString.append("]");
64 return regexString.toString();
65 }
66
67
68
69
70
71
72 @Override
73 public void extendExportMap(ExportMap exportMap) {
74 exportMap.set("type", "broaderAnyCharacter");
75
76 if (allowWhitespace) {
77 exportMap.set("allowWhitespace", "true");
78 }
79 }
80
81
82
83 @Override
84 protected String getValidationErrorMessageKeyOptions() {
85 if (getAllowWhitespace()) {
86 return ".allowWhitespace";
87 }
88 return KRADConstants.EMPTY_STRING;
89 }
90
91 }