%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.turbine.services.intake.validator.NumberValidator |
|
|
1 | package org.apache.turbine.services.intake.validator; |
|
2 | ||
3 | /* |
|
4 | * Copyright 2001-2005 The Apache Software Foundation. |
|
5 | * |
|
6 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
7 | * you may not use this file except in compliance with the License. |
|
8 | * You may obtain a copy of the License at |
|
9 | * |
|
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | * |
|
12 | * Unless required by applicable law or agreed to in writing, software |
|
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | * See the License for the specific language governing permissions and |
|
16 | * limitations under the License. |
|
17 | */ |
|
18 | ||
19 | import java.util.Map; |
|
20 | ||
21 | /** |
|
22 | * Validates numbers with the following constraints in addition to those |
|
23 | * listed in DefaultValidator. |
|
24 | * |
|
25 | * <table> |
|
26 | * <tr><th>Name</th><th>Valid Values</th><th>Default Value</th></tr> |
|
27 | * <tr><td>minValue</td><td>greater than BigDecimal.MIN_VALUE</td> |
|
28 | * <td> </td></tr> |
|
29 | * <tr><td>maxValue</td><td>less than BigDecimal.MAX_VALUE</td> |
|
30 | * <td> </td></tr> |
|
31 | * <tr><td>notANumberMessage</td><td>Some text</td> |
|
32 | * <td>Entry was not a valid number</td></tr> |
|
33 | * </table> |
|
34 | * |
|
35 | * @author <a href="mailto:jmcnally@collab.net">John McNally</a> |
|
36 | * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a> |
|
37 | * @author <a href="mailto:Colin.Chalmers@maxware.nl">Colin Chalmers</a> |
|
38 | * @version $Id: NumberValidator.java 264148 2005-08-29 14:21:04Z henning $ |
|
39 | */ |
|
40 | 0 | abstract class NumberValidator |
41 | extends DefaultValidator |
|
42 | { |
|
43 | /** The message to show if field fails min-value test */ |
|
44 | 0 | String minValueMessage = null; |
45 | ||
46 | /** The message to show if field fails max-value test */ |
|
47 | 0 | String maxValueMessage = null; |
48 | ||
49 | /** The message to use for invalid numbers */ |
|
50 | 0 | String invalidNumberMessage = null; |
51 | ||
52 | /** |
|
53 | * Extract the relevant parameters from the constraints listed |
|
54 | * in <rule> tags within the intake.xml file. |
|
55 | * |
|
56 | * @param paramMap a <code>Map</code> of <code>rule</code>'s |
|
57 | * containing constraints on the input. |
|
58 | * @exception InvalidMaskException an invalid mask was specified |
|
59 | */ |
|
60 | public void init(Map paramMap) |
|
61 | throws InvalidMaskException |
|
62 | { |
|
63 | 0 | super.init(paramMap); |
64 | ||
65 | 0 | Constraint constraint = |
66 | (Constraint) paramMap.get(INVALID_NUMBER_RULE_NAME); |
|
67 | ||
68 | 0 | if (constraint != null) |
69 | { |
|
70 | 0 | invalidNumberMessage = constraint.getMessage(); |
71 | } |
|
72 | 0 | } |
73 | ||
74 | // ************************************************************ |
|
75 | // ** Bean accessor methods ** |
|
76 | // ************************************************************ |
|
77 | ||
78 | /** |
|
79 | * Get the value of minValueMessage. |
|
80 | * |
|
81 | * @return value of minValueMessage. |
|
82 | */ |
|
83 | public String getMinValueMessage() |
|
84 | { |
|
85 | 0 | return minValueMessage; |
86 | } |
|
87 | ||
88 | /** |
|
89 | * Set the value of minValueMessage. |
|
90 | * |
|
91 | * @param minValueMessage Value to assign to minValueMessage. |
|
92 | */ |
|
93 | public void setMinValueMessage(String minValueMessage) |
|
94 | { |
|
95 | 0 | this.minValueMessage = minValueMessage; |
96 | 0 | } |
97 | ||
98 | /** |
|
99 | * Get the value of maxValueMessage. |
|
100 | * |
|
101 | * @return value of maxValueMessage. |
|
102 | */ |
|
103 | public String getMaxValueMessage() |
|
104 | { |
|
105 | 0 | return maxValueMessage; |
106 | } |
|
107 | ||
108 | /** |
|
109 | * Set the value of maxValueMessage. |
|
110 | * |
|
111 | * @param maxValueMessage Value to assign to maxValueMessage. |
|
112 | */ |
|
113 | public void setMaxValueMessage(String maxValueMessage) |
|
114 | { |
|
115 | 0 | this.maxValueMessage = maxValueMessage; |
116 | 0 | } |
117 | ||
118 | /** |
|
119 | * Get the value of invalidNumberMessage. |
|
120 | * |
|
121 | * @return value of invalidNumberMessage. |
|
122 | */ |
|
123 | public String getInvalidNumberMessage() |
|
124 | { |
|
125 | 0 | return invalidNumberMessage; |
126 | } |
|
127 | ||
128 | /** |
|
129 | * |
|
130 | * Set the value of invalidNumberMessage. |
|
131 | * @param invalidNumberMessage Value to assign to invalidNumberMessage. |
|
132 | */ |
|
133 | public void setInvalidNumberMessage(String invalidNumberMessage) |
|
134 | { |
|
135 | 0 | this.invalidNumberMessage = invalidNumberMessage; |
136 | 0 | } |
137 | ||
138 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |