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.kuali.rice.core.api.config.property.ConfigurationService;
19 import org.kuali.rice.krad.service.KRADServiceLocator;
20 import org.kuali.rice.krad.uif.UifConstants;
21
22 import java.util.ArrayList;
23 import java.util.List;
24
25
26
27
28
29
30
31
32
33
34 public abstract class AllowCharacterConstraint extends ValidCharactersPatternConstraint {
35 protected boolean allowWhitespace = false;
36 protected boolean omitNewline = false;
37 protected boolean allowUnderscore = false;
38 protected boolean allowPeriod = false;
39 protected boolean allowParenthesis = false;
40 protected boolean allowDollar = false;
41 protected boolean allowForwardSlash = false;
42 protected boolean allowDoubleQuote = false;
43 protected boolean allowApostrophe = false;
44 protected boolean allowComma = false;
45 protected boolean allowColon = false;
46 protected boolean allowSemiColon = false;
47 protected boolean allowQuestionMark = false;
48 protected boolean allowExclaimation = false;
49 protected boolean allowDash = false;
50 protected boolean allowPlus = false;
51 protected boolean allowEquals = false;
52 protected boolean allowAsterisk = false;
53 protected boolean allowAtSign = false;
54 protected boolean allowPercent = false;
55 protected boolean allowPound = false;
56 protected boolean allowGreaterThan = false;
57 protected boolean allowLessThan = false;
58 protected boolean allowBrackets = false;
59 protected boolean allowAmpersand = false;
60 protected boolean allowCurlyBraces = false;
61 protected boolean allowBackslash = false;
62 protected boolean allowAll = false;
63
64
65
66
67 public boolean isAllowWhitespace() {
68 return this.allowWhitespace;
69 }
70
71
72
73
74 public void setAllowWhitespace(boolean allowWhitespace) {
75 this.allowWhitespace = allowWhitespace;
76 }
77
78
79
80
81 public boolean isAllowUnderscore() {
82 return this.allowUnderscore;
83 }
84
85
86
87
88 public void setAllowUnderscore(boolean allowUnderscore) {
89 this.allowUnderscore = allowUnderscore;
90 }
91
92
93
94
95 public boolean isAllowPeriod() {
96 return this.allowPeriod;
97 }
98
99
100
101
102 public void setAllowPeriod(boolean allowPeriod) {
103 this.allowPeriod = allowPeriod;
104 }
105
106
107
108
109 public boolean isAllowParenthesis() {
110 return this.allowParenthesis;
111 }
112
113
114
115
116 public void setAllowParenthesis(boolean allowParenthesis) {
117 this.allowParenthesis = allowParenthesis;
118 }
119
120
121
122
123 public boolean isAllowDollar() {
124 return this.allowDollar;
125 }
126
127
128
129
130 public void setAllowDollar(boolean allowDollar) {
131 this.allowDollar = allowDollar;
132 }
133
134
135
136
137 public boolean isAllowForwardSlash() {
138 return this.allowForwardSlash;
139 }
140
141
142
143
144 public void setAllowForwardSlash(boolean allowForwardSlash) {
145 this.allowForwardSlash = allowForwardSlash;
146 }
147
148
149
150
151 public boolean isAllowDoubleQuote() {
152 return this.allowDoubleQuote;
153 }
154
155
156
157
158 public void setAllowDoubleQuote(boolean allowDoubleQuote) {
159 this.allowDoubleQuote = allowDoubleQuote;
160 }
161
162
163
164
165 public boolean isAllowApostrophe() {
166 return this.allowApostrophe;
167 }
168
169
170
171
172 public void setAllowApostrophe(boolean allowApostrophe) {
173 this.allowApostrophe = allowApostrophe;
174 }
175
176
177
178
179 public boolean isAllowComma() {
180 return this.allowComma;
181 }
182
183
184
185
186 public void setAllowComma(boolean allowComma) {
187 this.allowComma = allowComma;
188 }
189
190
191
192
193 public boolean isAllowColon() {
194 return this.allowColon;
195 }
196
197
198
199
200 public void setAllowColon(boolean allowColon) {
201 this.allowColon = allowColon;
202 }
203
204
205
206
207 public boolean isAllowSemiColon() {
208 return this.allowSemiColon;
209 }
210
211
212
213
214 public void setAllowSemiColon(boolean allowSemiColon) {
215 this.allowSemiColon = allowSemiColon;
216 }
217
218
219
220
221 public boolean isAllowQuestionMark() {
222 return this.allowQuestionMark;
223 }
224
225
226
227
228 public void setAllowQuestionMark(boolean allowQuestionMark) {
229 this.allowQuestionMark = allowQuestionMark;
230 }
231
232
233
234
235 public boolean isAllowExclaimation() {
236 return this.allowExclaimation;
237 }
238
239
240
241
242 public void setAllowExclaimation(boolean allowExclaimation) {
243 this.allowExclaimation = allowExclaimation;
244 }
245
246
247
248
249 public boolean isAllowDash() {
250 return this.allowDash;
251 }
252
253
254
255
256 public void setAllowDash(boolean allowDash) {
257 this.allowDash = allowDash;
258 }
259
260
261
262
263 public boolean isAllowPlus() {
264 return this.allowPlus;
265 }
266
267
268
269
270 public void setAllowPlus(boolean allowPlus) {
271 this.allowPlus = allowPlus;
272 }
273
274
275
276
277 public boolean isAllowEquals() {
278 return this.allowEquals;
279 }
280
281
282
283
284 public void setAllowEquals(boolean allowEquals) {
285 this.allowEquals = allowEquals;
286 }
287
288
289
290
291 public boolean isAllowAsterisk() {
292 return this.allowAsterisk;
293 }
294
295
296
297
298 public void setAllowAsterisk(boolean allowAsterisk) {
299 this.allowAsterisk = allowAsterisk;
300 }
301
302
303
304
305 public boolean isAllowAtSign() {
306 return this.allowAtSign;
307 }
308
309
310
311
312 public void setAllowAtSign(boolean allowAtSign) {
313 this.allowAtSign = allowAtSign;
314 }
315
316
317
318
319 public boolean isAllowPercent() {
320 return this.allowPercent;
321 }
322
323
324
325
326 public void setAllowPercent(boolean allowPercent) {
327 this.allowPercent = allowPercent;
328 }
329
330
331
332
333 public boolean isAllowPound() {
334 return this.allowPound;
335 }
336
337
338
339
340 public void setAllowPound(boolean allowPound) {
341 this.allowPound = allowPound;
342 }
343
344 public boolean isAllowGreaterThan() {
345 return allowGreaterThan;
346 }
347
348 public void setAllowGreaterThan(boolean allowGreaterThan) {
349 this.allowGreaterThan = allowGreaterThan;
350 }
351
352 public boolean isAllowLessThan() {
353 return allowLessThan;
354 }
355
356 public void setAllowLessThan(boolean allowLessThan) {
357 this.allowLessThan = allowLessThan;
358 }
359
360 public boolean isAllowBrackets() {
361 return allowBrackets;
362 }
363
364 public void setAllowBrackets(boolean allowBrackets) {
365 this.allowBrackets = allowBrackets;
366 }
367
368 public boolean isAllowAmpersand() {
369 return allowAmpersand;
370 }
371
372 public void setAllowAmpersand(boolean allowAmpersand) {
373 this.allowAmpersand = allowAmpersand;
374 }
375
376 public boolean isAllowCurlyBraces() {
377 return allowCurlyBraces;
378 }
379
380 public void setAllowCurlyBraces(boolean allowCurlyBraces) {
381 this.allowCurlyBraces = allowCurlyBraces;
382 }
383
384 public boolean isAllowBackslash() {
385 return allowBackslash;
386 }
387
388 public void setAllowBackslash(boolean allowBackslash) {
389 this.allowBackslash = allowBackslash;
390 }
391
392
393
394
395
396
397
398 public boolean isAllowAll() {
399 return this.allowAll;
400 }
401
402
403
404
405 public void setAllowAll(boolean allowAll) {
406 this.allowAll = allowAll;
407 }
408
409 public boolean isOmitNewline() {
410 return omitNewline;
411 }
412
413
414
415
416
417
418
419
420 public void setOmitNewline(boolean omitNewline) {
421 this.omitNewline = omitNewline;
422 }
423
424
425
426
427
428
429
430
431 protected String getAllowedCharacterRegex() {
432 StringBuilder regexString = new StringBuilder("");
433 if (allowWhitespace || allowAll) {
434 regexString.append("\\t\\v\\040");
435 if (!omitNewline) {
436 regexString.append("\\f\\r\\n");
437 }
438 }
439 if (allowUnderscore || allowAll) {
440 regexString.append("_");
441 }
442 if (allowPeriod || allowAll) {
443 regexString.append(".");
444 }
445 if (allowParenthesis || allowAll) {
446 regexString.append("(");
447 regexString.append(")");
448 }
449 if (allowDollar || allowAll) {
450 regexString.append("$");
451 }
452 if (allowForwardSlash || allowAll) {
453 regexString.append("/");
454 }
455 if (allowDoubleQuote || allowAll) {
456 regexString.append("\\\"");
457 }
458 if (allowApostrophe || allowAll) {
459 regexString.append("'");
460 }
461 if (allowComma || allowAll) {
462 regexString.append(",");
463 }
464 if (allowColon || allowAll) {
465 regexString.append(":");
466 }
467 if (allowSemiColon || allowAll) {
468 regexString.append(";");
469 }
470 if (allowQuestionMark || allowAll) {
471 regexString.append("?");
472 }
473 if (allowExclaimation || allowAll) {
474 regexString.append("!");
475 }
476 if (allowDash || allowAll) {
477 regexString.append("\\-");
478 }
479 if (allowPlus || allowAll) {
480 regexString.append("+");
481 }
482 if (allowEquals || allowAll) {
483 regexString.append("=");
484 }
485 if (allowAsterisk || allowAll) {
486 regexString.append("*");
487 }
488 if (allowAtSign || allowAll) {
489 regexString.append("@");
490 }
491 if (allowPercent || allowAll) {
492 regexString.append("%");
493 }
494 if (allowPound || allowAll) {
495 regexString.append("#");
496 }
497 if (allowLessThan || allowAll) {
498 regexString.append("\\0074");
499 }
500 if (allowGreaterThan || allowAll) {
501 regexString.append("\\0076");
502 }
503 if (allowAmpersand || allowAll) {
504 regexString.append("\\0046");
505 }
506 if (allowBackslash || allowAll) {
507 regexString.append("\\0134");
508 }
509 if (allowCurlyBraces || allowAll) {
510 regexString.append("\\0173\\0175");
511 }
512 if (allowBrackets || allowAll) {
513 regexString.append("\\0133\\0135");
514 }
515 return regexString.toString();
516 }
517
518
519
520
521
522
523
524 public List<String> getValidationMessageParams() {
525 if (validationMessageParams == null) {
526 validationMessageParams = new ArrayList<String>();
527 ConfigurationService configService = KRADServiceLocator.getKualiConfigurationService();
528 StringBuilder paramString = new StringBuilder("");
529
530 if (allowWhitespace || allowAll) {
531 paramString.append(", " + configService.getPropertyValueAsString(
532 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "whitespace"));
533 if (!omitNewline) {
534 paramString.append(", " + configService.getPropertyValueAsString(
535 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "newline"));
536 }
537 }
538 if (allowUnderscore || allowAll) {
539 paramString.append(", " + configService.getPropertyValueAsString(
540 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "underscore"));
541 }
542 if (allowPeriod || allowAll) {
543 paramString.append(", " + configService.getPropertyValueAsString(
544 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "period"));
545 }
546 if (allowParenthesis || allowAll) {
547 paramString.append(", " + configService.getPropertyValueAsString(
548 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "parenthesis"));
549 }
550 if (allowDollar || allowAll) {
551 paramString.append(", " + configService.getPropertyValueAsString(
552 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "dollar"));
553 }
554 if (allowForwardSlash || allowAll) {
555 paramString.append(", " + configService.getPropertyValueAsString(
556 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "forwardSlash"));
557 }
558 if (allowDoubleQuote || allowAll) {
559 paramString.append(", " + configService.getPropertyValueAsString(
560 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "doubleQuote"));
561 }
562 if (allowApostrophe || allowAll) {
563 paramString.append(", " + configService.getPropertyValueAsString(
564 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "apostrophe"));
565 }
566 if (allowComma || allowAll) {
567 paramString.append(", " + configService.getPropertyValueAsString(
568 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "comma"));
569 }
570 if (allowColon || allowAll) {
571 paramString.append(", " + configService.getPropertyValueAsString(
572 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "colon"));
573 }
574 if (allowSemiColon || allowAll) {
575 paramString.append(", " + configService.getPropertyValueAsString(
576 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "semiColon"));
577 }
578 if (allowQuestionMark || allowAll) {
579 paramString.append(", " + configService.getPropertyValueAsString(
580 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "questionMark"));
581 }
582 if (allowExclaimation || allowAll) {
583 paramString.append(", " + configService.getPropertyValueAsString(
584 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "exclaimation"));
585 }
586 if (allowDash || allowAll) {
587 paramString.append(", " + configService.getPropertyValueAsString(
588 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "dash"));
589 }
590 if (allowPlus || allowAll) {
591 paramString.append(", " + configService.getPropertyValueAsString(
592 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "plus"));
593 }
594 if (allowEquals || allowAll) {
595 paramString.append(", " + configService.getPropertyValueAsString(
596 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "equals"));
597 }
598 if (allowAsterisk || allowAll) {
599 paramString.append(", " + configService.getPropertyValueAsString(
600 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "asterisk"));
601 }
602 if (allowAtSign || allowAll) {
603 paramString.append(", " + configService.getPropertyValueAsString(
604 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "atSign"));
605 }
606 if (allowPercent || allowAll) {
607 paramString.append(", " + configService.getPropertyValueAsString(
608 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "percent"));
609 }
610 if (allowPound || allowAll) {
611 paramString.append(", " + configService.getPropertyValueAsString(
612 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "pound"));
613 }
614 if (allowLessThan || allowAll) {
615 paramString.append(", " + configService.getPropertyValueAsString(
616 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "lessThan"));
617 }
618 if (allowGreaterThan || allowAll) {
619 paramString.append(", " + configService.getPropertyValueAsString(
620 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "greaterThan"));
621 }
622 if (allowAmpersand || allowAll) {
623 paramString.append(", " + configService.getPropertyValueAsString(
624 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "ampersand"));
625 }
626 if (allowBackslash || allowAll) {
627 paramString.append(", " + configService.getPropertyValueAsString(
628 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "backslash"));
629 }
630 if (allowCurlyBraces || allowAll) {
631 paramString.append(", " + configService.getPropertyValueAsString(
632 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "curlyBraces"));
633 }
634 if (allowBrackets || allowAll) {
635 paramString.append(", " + configService.getPropertyValueAsString(
636 UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "brackets"));
637 }
638
639 validationMessageParams.add(paramString.toString());
640 }
641 return this.validationMessageParams;
642 }
643
644 }