org.iscreen.validators
Class NumberRangeValidator

java.lang.Object
  extended by org.iscreen.BaseValidator
      extended by org.iscreen.validators.NumberRangeValidator
All Implemented Interfaces:
Validator

public class NumberRangeValidator
extends BaseValidator

This validator verifies that a passed in java.lang.Number is within a certain range.

This validator takes two constraints:
minimumValue - The smallest number the value can be.
maximumValue - The largest number the value can be (-1 means infinite).

This validator takes two failure messages:
rangeFailure - Failure when the value it outside the range.
invalidNumberFailure - Failure when the value is not a java.lang.Number.

Author:
Shellman, Dan

Field Summary
 
Fields inherited from class org.iscreen.BaseValidator
defaultFailure
 
Constructor Summary
NumberRangeValidator()
          Default constructor.
 
Method Summary
 java.lang.Integer getMaximumValue()
           
 java.lang.Integer getMinimumValue()
           
protected  int getNumber(java.lang.Object obj)
           
 void setInvalidNumberFailure(FailureMessage message)
           
 void setMaximumValue(java.lang.Integer maxValue)
           
 void setMinimumValue(java.lang.Integer minValue)
           
 void setRangeFailure(FailureMessage message)
           
 void validate(ValidatorContext context, java.lang.Object objectToValidate)
          This is the method that's called to validate the "bean-to-validate." Use the passed in ValidatorContext to report validation failures, etc.
 
Methods inherited from class org.iscreen.BaseValidator
constructBeanToValidate, getDefaultFailure, getStringValue, getValue, setDefaultFailure
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberRangeValidator

public NumberRangeValidator()
Default constructor.

Method Detail

validate

public void validate(ValidatorContext context,
                     java.lang.Object objectToValidate)
Description copied from interface: Validator
This is the method that's called to validate the "bean-to-validate." Use the passed in ValidatorContext to report validation failures, etc. The passed-in "bean-to-validate" is the same instance returned from the call to constructBeanToValidate(), but with all of the appropriate properties set (based upon the configured mapping).

Parameters:
context - The ValidatorContext, which is used to report failures.
objectToValidate - The JavaBean to validate.

setMinimumValue

public void setMinimumValue(java.lang.Integer minValue)

getMinimumValue

public java.lang.Integer getMinimumValue()

setMaximumValue

public void setMaximumValue(java.lang.Integer maxValue)

getMaximumValue

public java.lang.Integer getMaximumValue()

setRangeFailure

public void setRangeFailure(FailureMessage message)

setInvalidNumberFailure

public void setInvalidNumberFailure(FailureMessage message)

getNumber

protected int getNumber(java.lang.Object obj)