View Javadoc
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 Longs 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 Long.MIN_VALUE</td>
32   * <td>&nbsp;</td></tr>
33   * <tr><td>maxValue</td><td>less than Long.MAX_VALUE</td>
34   * <td>&nbsp;</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&uuml;rgen Hoffmann</a>
42   * @version $Id$
43   */
44  public class LongValidator
45          extends NumberValidator<Long>
46  {
47      /**
48       * Default Constructor
49       */
50      public LongValidator()
51      {
52          super();
53          invalidNumberMessage = "Entry was not a valid Long";
54      }
55  
56      /**
57       * @see org.apache.fulcrum.intake.validator.NumberValidator#parseNumber(java.lang.String, java.util.Locale)
58       */
59      @Override
60      protected Long parseNumber(String stringValue, Locale locale) throws NumberFormatException
61      {
62          return Long.valueOf(stringValue);
63      }
64  }