org.apache.wicket.validation.validator
Class NumberValidator

java.lang.Object
  extended by org.apache.wicket.validation.validator.AbstractValidator
      extended by org.apache.wicket.validation.validator.NumberValidator
All Implemented Interfaces:
java.io.Serializable, IClusterable, INullAcceptingValidator, IValidator
Direct Known Subclasses:
NumberValidator.DoubleMaximumValidator, NumberValidator.DoubleMinimumValidator, NumberValidator.DoubleRangeValidator, NumberValidator.MaximumValidator, NumberValidator.MinimumValidator, NumberValidator.RangeValidator

public abstract class NumberValidator
extends AbstractValidator

Validator for checking numbers. Use the static factory methods to make range/minimum or maximum validators for doubles or longs.

Since:
1.2.6
Author:
Jonathan Locke, Johan Compagner, Igor Vaynberg (ivaynberg)
See Also:
Serialized Form

Nested Class Summary
static class NumberValidator.DoubleMaximumValidator
          Validator for checking if a given double meets a maximum requirement.
static class NumberValidator.DoubleMinimumValidator
          Validator for checking if a given double meets the minimum requirement.
static class NumberValidator.DoubleRangeValidator
          Validator for checking if a given double is within the specified range.
static class NumberValidator.MaximumValidator
          Validator for checking if a given number meets the maximum requirement.
static class NumberValidator.MinimumValidator
          Validator for checking if a given number number meets the minimum requirement.
static class NumberValidator.RangeValidator
          Validator for checking if a given number is within the specified range.
 
Field Summary
static NumberValidator NEGATIVE
          a validator for ensuring a negative number value (<0 so not including 0)
static NumberValidator POSITIVE
          a validator for ensuring for a positive number value (>0 so not including 0)
 
Constructor Summary
NumberValidator()
           
 
Method Summary
static NumberValidator maximum(double maximum)
          Gets a Double maximum validator for checking if an number is smaller than or equal to the given maximum value.
static NumberValidator maximum(long maximum)
          Gets an Integer range validator for checking if a number is smaller than or equal to the given maximum value.
static NumberValidator minimum(double minimum)
          Gets a Double minimum validator for checking if number is greater then or equal to the given minimum value.
static NumberValidator minimum(long minimum)
          Gets an Integer minimum validator for checking if a number is greater than or equal to the given minimum value.
static NumberValidator range(double minimum, double maximum)
          Gets a Double range validator for checking if a number falls between (including) the minimum and maximum values.
static NumberValidator range(long minimum, long maximum)
          Gets an Integer range validator for checking if a number falls between the minimum and maximum values.
 
Methods inherited from class org.apache.wicket.validation.validator.AbstractValidator
error, error, error, error, messageModel, onValidate, resourceKey, resourceKey, validate, validate, validateOnNullValue, variablesMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POSITIVE

public static final NumberValidator POSITIVE
a validator for ensuring for a positive number value (>0 so not including 0)


NEGATIVE

public static final NumberValidator NEGATIVE
a validator for ensuring a negative number value (<0 so not including 0)

Constructor Detail

NumberValidator

public NumberValidator()
Method Detail

range

public static NumberValidator range(long minimum,
                                    long maximum)
Gets an Integer range validator for checking if a number falls between the minimum and maximum values. If that is not the case, an error message will be generated with the key "NumberValidator.range". The message keys that can be used are:

Parameters:
minimum - the minimum value
maximum - the maximum value
Returns:
the request NumberValidator

minimum

public static NumberValidator minimum(long minimum)
Gets an Integer minimum validator for checking if a number is greater than or equal to the given minimum value. If that is not the case, an error message will be generated with the key "NumberValidator.minimum". The message keys that can be used are:

Parameters:
minimum - the minimum value
Returns:
the requested NumberValidator

maximum

public static NumberValidator maximum(long maximum)
Gets an Integer range validator for checking if a number is smaller than or equal to the given maximum value. If that is not the case, an error message will be generated with the key "NumberValidator.maximum". The message keys that can be used are:

Parameters:
maximum - the maximum value
Returns:
the requested NumberValidator

range

public static NumberValidator range(double minimum,
                                    double maximum)
Gets a Double range validator for checking if a number falls between (including) the minimum and maximum values. If that is not the case, an error message will be generated with the key "NumberValidator.range". The message keys that can be used are:

Parameters:
minimum - the minimum value
maximum - the maximum value
Returns:
the requested NumberValidator

minimum

public static NumberValidator minimum(double minimum)
Gets a Double minimum validator for checking if number is greater then or equal to the given minimum value. If that is not the case, an error message will be generated with the key "NumberValidator.minimum". The message keys that can be used are:

Parameters:
minimum - the minimum value
Returns:
the requested NumberValidator

maximum

public static NumberValidator maximum(double maximum)
Gets a Double maximum validator for checking if an number is smaller than or equal to the given maximum value. If that is not the case, an error message will be generated with the key "NumberValidator.maximum". The message keys that can be used are:

Parameters:
maximum - the maximum value
Returns:
the requested NumberValidator


Copyright © 2004-2010 Apache Software Foundation. All Rights Reserved.