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
21
22
23
24
25
26
27
28 @Deprecated
29 public class AlphaNumericValidationPattern extends CharacterLevelValidationPattern {
30 protected boolean allowWhitespace = false;
31 protected boolean allowUnderscore = false;
32 protected boolean allowPeriod = false;
33
34 protected boolean allowParenthesis = false;
35 protected boolean allowDollar = false;
36 protected boolean allowForwardSlash = false;
37 protected boolean lowerCase = false;
38 protected boolean allowDash = false;
39
40
41
42
43 public boolean getAllowPeriod() {
44 return allowPeriod;
45 }
46
47
48
49
50 public void setAllowPeriod(boolean allowPeriod) {
51 this.allowPeriod = allowPeriod;
52 }
53
54
55
56
57 public boolean isAllowPeriod() {
58 return allowPeriod;
59 }
60
61
62
63
64 public boolean isAllowParenthesis() {
65 return allowParenthesis;
66 }
67
68
69
70
71 public void setAllowParenthesis(boolean allowParenthesis) {
72 this.allowParenthesis = allowParenthesis;
73 }
74
75
76
77
78 public boolean isAllowDollar() {
79 return allowDollar;
80 }
81
82
83
84
85 public void setAllowDollar(boolean allowDollar) {
86 this.allowDollar = allowDollar;
87 }
88
89
90
91
92 public boolean isAllowForwardSlash() {
93 return allowForwardSlash;
94 }
95
96
97
98
99 public void setAllowForwardSlash(boolean allowForwardSlash) {
100 this.allowForwardSlash = allowForwardSlash;
101 }
102
103
104
105
106 public boolean getAllowWhitespace() {
107 return allowWhitespace;
108 }
109
110
111
112
113 public void setAllowWhitespace(boolean allowWhitespace) {
114 this.allowWhitespace = allowWhitespace;
115 }
116
117
118
119
120
121 public boolean getAllowUnderscore() {
122 return allowUnderscore;
123 }
124
125
126
127
128 public void setAllowUnderscore(boolean allowUnderscore) {
129 this.allowUnderscore = allowUnderscore;
130 }
131
132
133
134
135 public boolean isLowerCase() {
136 return this.lowerCase;
137 }
138
139
140
141
142 public void setLowerCase(boolean lowerCase) {
143 this.lowerCase = lowerCase;
144 }
145
146
147
148
149 public boolean getAllowDash() {
150 return allowDash;
151 }
152
153
154
155
156 public void setAllowDash(boolean allowDash) {
157 this.allowDash = allowDash;
158 }
159
160
161
162
163 protected String getRegexString() {
164 StringBuilder regexString = new StringBuilder("[A-Za-z0-9");
165
166
167
168
169 if(lowerCase){
170 regexString = new StringBuilder("[a-z0-9");
171 }
172
173 if (allowWhitespace) {
174 regexString.append("\\s");
175 }
176 if (allowUnderscore) {
177 regexString.append("_");
178 }
179 if (allowPeriod) {
180 regexString.append(".");
181 }
182 if(allowParenthesis) {
183 regexString.append("(");
184 regexString.append(")");
185 }
186 if(allowDollar) {
187 regexString.append("$");
188 }
189 if(allowForwardSlash) {
190 regexString.append("/");
191 }
192 if (allowDash) {
193 regexString.append("-");
194 }
195 regexString.append("]");
196
197 return regexString.toString();
198 }
199
200
201
202
203
204 public void extendExportMap(ExportMap exportMap) {
205 exportMap.set("type", "alphaNumeric");
206
207 if (lowerCase) {
208 exportMap.set("allowUpperCase", "true");
209 }
210 if (allowWhitespace) {
211 exportMap.set("allowWhitespace", "true");
212 }
213 if (allowUnderscore) {
214 exportMap.set("allowUnderscore", "true");
215 }
216 if (allowPeriod) {
217 exportMap.set("allowPeriod", "true");
218 }
219 if(allowParenthesis) {
220 exportMap.set("allowParenthesis", "true");
221
222 }
223 if(allowDollar) {
224 exportMap.set("allowDollar", "true");
225
226 }
227 if(allowForwardSlash) {
228 exportMap.set("allowForwardSlash", "true");
229
230 }
231 if (allowDash) {
232 exportMap.set("allowDash", "true");
233 }
234 }
235
236 @Override
237 protected String getValidationErrorMessageKeyOptions() {
238 final StringBuilder opts = new StringBuilder();
239
240 if (lowerCase) {
241 opts.append(".lowerCase");
242 }
243 if (allowWhitespace) {
244 opts.append(".allowWhitespace");
245 }
246 if (allowUnderscore) {
247 opts.append(".allowUnderscore");
248 }
249 if (allowPeriod) {
250 opts.append(".allowPeriod");
251 }
252 if(allowParenthesis) {
253 opts.append(".allowParenthesis");
254 }
255 if(allowDollar) {
256 opts.append(".allowDollar");
257 }
258 if(allowForwardSlash) {
259 opts.append(".allowForwardSlash");
260 }
261 if (allowDash) {
262 opts.append(".allowDash");
263 }
264
265 return opts.toString();
266 }
267 }