1 package org.apache.fulcrum.intake.validator;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import java.util.Locale;
23
24 /**
25 * Validates Integers with the following constraints in addition to those
26 * listed in NumberValidator and DefaultValidator.
27 *
28 * <table>
29 * <caption>Validation rules</caption>
30 * <tr><th>Name</th><th>Valid Values</th><th>Default Value</th></tr>
31 * <tr><td>minValue</td><td>greater than Integer.MIN_VALUE</td>
32 * <td> </td></tr>
33 * <tr><td>maxValue</td><td>less than Integer.MAX_VALUE</td>
34 * <td> </td></tr>
35 * <tr><td>invalidNumberMessage</td><td>Some text</td>
36 * <td>Entry was not a valid number</td></tr>
37 * </table>
38 *
39 * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
40 * @author <a href="mailto:Colin.Chalmers@maxware.nl">Colin Chalmers</a>
41 * @author <a href="mailto:jh@byteaction.de">Jürgen Hoffmann</a>
42 * @version $Id$
43 */
44 public class IntegerValidator
45 extends NumberValidator<Integer>
46 {
47 /**
48 * Default Constructor
49 */
50 public IntegerValidator()
51 {
52 super();
53 invalidNumberMessage = "Entry was not a valid Integer";
54 }
55
56 /**
57 * @see org.apache.fulcrum.intake.validator.NumberValidator#parseNumber(java.lang.String, java.util.Locale)
58 */
59 @Override
60 protected Integer parseNumber(String stringValue, Locale locale) throws NumberFormatException
61 {
62 return Integer.valueOf(stringValue);
63 }
64 }