1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.datadictionary.validation.fieldlevel;
17
18 import org.kuali.rice.krad.datadictionary.exporter.ExportMap;
19 import org.kuali.rice.krad.datadictionary.validation.FieldLevelValidationPattern;
20
21
22
23
24
25
26 @Deprecated
27 public class FloatingPointValidationPattern extends FieldLevelValidationPattern {
28 protected boolean allowNegative;
29
30
31
32
33 public boolean getAllowNegative() {
34 return allowNegative;
35 }
36
37
38
39
40 public void setAllowNegative(boolean allowNegative) {
41 this.allowNegative = allowNegative;
42 }
43
44
45
46
47
48
49 protected String getRegexString() {
50 StringBuffer regex = new StringBuffer();
51
52 if (allowNegative) {
53 regex.append("-?");
54 }
55 regex.append(super.getRegexString());
56
57 return regex.toString();
58 }
59
60
61
62
63 protected String getPatternTypeName() {
64 return "floatingPoint";
65 }
66
67
68
69
70
71 public ExportMap buildExportMap(String exportKey) {
72 ExportMap exportMap = super.buildExportMap(exportKey);
73
74 if (allowNegative) {
75 exportMap.set("allowNegative", "true");
76 }
77
78 return exportMap;
79 }
80
81
82
83
84 @Override
85 public String getValidationErrorMessageKey() {
86 StringBuilder buf = new StringBuilder();
87 buf.append("error.format.").append(getClass().getName());
88 if (allowNegative) {
89 buf.append(".allowNegative");
90 }
91 return buf.toString();
92 }
93 }