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 java.util.ArrayList;
19 import java.util.List;
20
21 import org.kuali.rice.core.api.config.property.ConfigurationService;
22 import org.kuali.rice.krad.service.KRADServiceLocator;
23 import org.kuali.rice.krad.uif.UifConstants;
24
25
26
27
28
29
30 public class FloatingPointPatternConstraint extends ConfigurationBasedRegexPatternConstraint {
31
32 protected boolean allowNegative;
33
34
35
36
37 @Override
38 protected String getRegexString() {
39 StringBuffer regex = new StringBuffer();
40
41 if (isAllowNegative()) {
42 regex.append("-?");
43 }
44 regex.append(super.getRegexString());
45
46 return regex.toString();
47 }
48
49
50
51
52 public boolean isAllowNegative() {
53 return this.allowNegative;
54 }
55
56
57
58
59 public void setAllowNegative(boolean allowNegative) {
60 this.allowNegative = allowNegative;
61 }
62
63
64
65
66
67
68 @Override
69 public List<String> getValidationMessageParams() {
70 if (validationMessageParams == null) {
71 validationMessageParams = new ArrayList<String>();
72 ConfigurationService configService = KRADServiceLocator.getKualiConfigurationService();
73 if (allowNegative) {
74 validationMessageParams.add(configService
75 .getPropertyValueAsString(UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX
76 + "positiveOrNegative"));
77 } else {
78 validationMessageParams.add(configService
79 .getPropertyValueAsString(UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "positive"));
80 }
81 }
82 return validationMessageParams;
83 }
84 }