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