Klasse NumberValidator<T extends Number>

java.lang.Object
org.apache.fulcrum.intake.validator.DefaultValidator<T>
org.apache.fulcrum.intake.validator.NumberValidator<T>
Alle implementierten Schnittstellen:
org.apache.avalon.framework.logger.LogEnabled, InitableByConstraintMap, Validator<T>
Bekannte direkte Unterklassen:
BigDecimalValidator, DoubleValidator, FloatValidator, IntegerValidator, LongValidator, ShortValidator

public abstract class NumberValidator<T extends Number> extends DefaultValidator<T>
Validates numbers with the following constraints in addition to those listed in DefaultValidator.
Validation rules
NameValid ValuesDefault Value
minValuegreater than BigDecimal.MIN_VALUE  
maxValueless than BigDecimal.MAX_VALUE  
notANumberMessageSome text Entry was not a valid number
Version:
$Id$
Autor:
John McNally, Quinton McCombs, Colin Chalmers
  • Konstruktordetails

    • NumberValidator

      public NumberValidator()
      Default Constructor
  • Methodendetails

    • init

      public void init(Map<String,? extends Constraint> paramMap) throws InvalidMaskException
      Extract the relevant parameters from the constraints listed in <rule> tags within the intake.xml file.
      Angegeben von:
      init in Schnittstelle InitableByConstraintMap
      Setzt außer Kraft:
      init in Klasse DefaultValidator<T extends Number>
      Parameter:
      paramMap - a Map of rule's containing constraints on the input.
      Löst aus:
      InvalidMaskException - an invalid mask was specified
    • parseNumber

      protected abstract T parseNumber(String stringValue, Locale locale) throws NumberFormatException
      Parse the actual value out of a string
      Parameter:
      stringValue - the string value
      locale - the locale to use while parsing
      Gibt zurück:
      the value
      Löst aus:
      NumberFormatException - if the value could not be parsed
    • parseIntoNumber

      protected Number parseIntoNumber(String stringValue, Locale locale) throws NumberFormatException
      Helper method to parse a number object out of a string
      Parameter:
      stringValue - the string value
      locale - the locale to use while parsing
      Gibt zurück:
      the Number
      Löst aus:
      NumberFormatException - if the value could not be parsed
    • assertValidity

      public void assertValidity(Field<T> field) throws ValidationException
      Determine whether a field meets the criteria specified in the constraints defined for this validator
      Angegeben von:
      assertValidity in Schnittstelle Validator<T extends Number>
      Setzt außer Kraft:
      assertValidity in Klasse DefaultValidator<T extends Number>
      Parameter:
      field - a Field to be tested
      Löst aus:
      ValidationException - containing an error message if the testValue did not pass the validation tests.
    • assertValidity

      public void assertValidity(String testValue, Locale locale) throws ValidationException
      Determine whether a testValue meets the criteria specified in the constraints defined for this validator
      Parameter:
      testValue - a String to be tested
      locale - the Locale of the associated field
      Löst aus:
      ValidationException - containing an error message if the testValue did not pass the validation tests.
    • getMinValueMessage

      public String getMinValueMessage()
      Get the value of minValueMessage.
      Gibt zurück:
      value of minValueMessage.
    • setMinValueMessage

      public void setMinValueMessage(String minValueMessage)
      Set the value of minValueMessage.
      Parameter:
      minValueMessage - Value to assign to minValueMessage.
    • getMaxValueMessage

      public String getMaxValueMessage()
      Get the value of maxValueMessage.
      Gibt zurück:
      value of maxValueMessage.
    • setMaxValueMessage

      public void setMaxValueMessage(String maxValueMessage)
      Set the value of maxValueMessage.
      Parameter:
      maxValueMessage - Value to assign to maxValueMessage.
    • getInvalidNumberMessage

      public String getInvalidNumberMessage()
      Get the value of invalidNumberMessage.
      Gibt zurück:
      value of invalidNumberMessage.
    • setInvalidNumberMessage

      public void setInvalidNumberMessage(String invalidNumberMessage)
      Set the value of invalidNumberMessage.
      Parameter:
      invalidNumberMessage - Value to assign to invalidNumberMessage.
    • getMinValue

      public T getMinValue()
      Get the value of minValue.
      Gibt zurück:
      value of minValue.
    • setMinValue

      public void setMinValue(T minValue)
      Set the value of minValue.
      Parameter:
      minValue - Value to assign to minValue.
    • getMaxValue

      public T getMaxValue()
      Get the value of maxValue.
      Gibt zurück:
      value of maxValue.
    • setMaxValue

      public void setMaxValue(T maxValue)
      Set the value of maxValue.
      Parameter:
      maxValue - Value to assign to maxValue.