net.sf.mmm.util.value.base
Class ValueValidatorNumberRange

java.lang.Object
  extended by net.sf.mmm.util.component.base.AbstractComponent
      extended by net.sf.mmm.util.component.base.AbstractLoggableComponent
          extended by net.sf.mmm.util.value.base.AbstractValueValidator<Number>
              extended by net.sf.mmm.util.value.base.ValueValidatorNumberRange
All Implemented Interfaces:
ValueValidator<Number>

public class ValueValidatorNumberRange
extends AbstractValueValidator<Number>

This is an implementation of ValueValidator that validates if a Number is in a specific range.

Since:
2.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)
See Also:
ValueOutOfRangeException.checkRange(Number, Number, Number, Object)

Field Summary
private  Double maximum
           
private  Double minimum
           
 
Constructor Summary
ValueValidatorNumberRange(Double minimum, Double maximum)
          The constructor.
 
Method Summary
 void validate(Number value, Object valueSource)
          This method validates the given value.
 
Methods inherited from class net.sf.mmm.util.value.base.AbstractValueValidator
validate
 
Methods inherited from class net.sf.mmm.util.component.base.AbstractLoggableComponent
doInitialize, getLogger, setLogger
 
Methods inherited from class net.sf.mmm.util.component.base.AbstractComponent
doInitialized, getInitializationState, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

minimum

private final Double minimum
See Also:
ValueValidatorNumberRange(Double, Double)

maximum

private final Double maximum
See Also:
ValueValidatorNumberRange(Double, Double)
Constructor Detail

ValueValidatorNumberRange

public ValueValidatorNumberRange(Double minimum,
                                 Double maximum)
The constructor.

Parameters:
minimum - is the minimum value that is valid or null for no minimum.
maximum - is the maximum value that is valid or null for no maximum.
Method Detail

validate

public void validate(Number value,
                     Object valueSource)
              throws RuntimeException
This method validates the given value. If the value is invalid, a RuntimeException is thrown. Otherwise this method will return without any side-effect.

Parameters:
value - is the value to validate.
valueSource - describes the origin of the given value. This may be the filename where the value was read from, an XPath where the value was located in an XML document, etc. It can be used in exceptions thrown if the value is invalid. This will help to find the problem easier. It may be null if there is no helpful source available but you should prefer ValueValidator.validate(Object) in such case.
Throws:
RuntimeException - if the given value in invalid.


Copyright © 2001-2010 mmm-Team. All Rights Reserved.