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
Validates numbers with the following constraints in addition to those
listed in DefaultValidator.
Name | Valid Values | Default Value |
---|---|---|
minValue | greater than BigDecimal.MIN_VALUE | |
maxValue | less than BigDecimal.MAX_VALUE | |
notANumberMessage | Some text | Entry was not a valid number |
- Version:
- $Id$
- Autor:
- John McNally, Quinton McCombs, Colin Chalmers
-
Feldübersicht
Von Klasse geerbte Felder org.apache.fulcrum.intake.validator.DefaultValidator
errorMessage, log, maxLength, maxLengthMessage, minLength, minLengthMessage, required, requiredMessage
Von Schnittstelle geerbte Felder org.apache.fulcrum.intake.validator.Validator
FLEXIBLE_RULE_NAME, FORMAT_RULE_NAME, INVALID_NUMBER_RULE_NAME, MASK_RULE_NAME, MAX_LENGTH_RULE_NAME, MAX_VALUE_RULE_NAME, MIN_LENGTH_RULE_NAME, MIN_VALUE_RULE_NAME, REQUIRED_RULE_NAME
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
assertValidity
(String testValue, Locale locale) Determine whether a testValue meets the criteria specified in the constraints defined for this validatorvoid
assertValidity
(Field<T> field) Determine whether a field meets the criteria specified in the constraints defined for this validatorGet the value of invalidNumberMessage.Get the value of maxValue.Get the value of maxValueMessage.Get the value of minValue.Get the value of minValueMessage.void
init
(Map<String, ? extends Constraint> paramMap) Extract the relevant parameters from the constraints listed in <rule> tags within the intake.xml file.protected Number
parseIntoNumber
(String stringValue, Locale locale) Helper method to parse a number object out of a stringprotected abstract T
parseNumber
(String stringValue, Locale locale) Parse the actual value out of a stringvoid
setInvalidNumberMessage
(String invalidNumberMessage) Set the value of invalidNumberMessage.void
setMaxValue
(T maxValue) Set the value of maxValue.void
setMaxValueMessage
(String maxValueMessage) Set the value of maxValueMessage.void
setMinValue
(T minValue) Set the value of minValue.void
setMinValueMessage
(String minValueMessage) Set the value of minValueMessage.Von Klasse geerbte Methoden org.apache.fulcrum.intake.validator.DefaultValidator
assertValidity, enableLogging, getMaxLength, getMaxLengthMessage, getMessage, getMinLength, getMinLengthMessage, getRequiredMessage, isRequired, isValid, isValid, setMaxLength, setMaxLengthMessage, setMinLength, setMinLengthMessage, setRequired, setRequiredMessage
-
Konstruktordetails
-
NumberValidator
public NumberValidator()Default Constructor
-
-
Methodendetails
-
init
Extract the relevant parameters from the constraints listed in <rule> tags within the intake.xml file.- Angegeben von:
init
in SchnittstelleInitableByConstraintMap
- Setzt außer Kraft:
init
in KlasseDefaultValidator<T extends Number>
- Parameter:
paramMap
- aMap
ofrule
's containing constraints on the input.- Löst aus:
InvalidMaskException
- an invalid mask was specified
-
parseNumber
Parse the actual value out of a string- Parameter:
stringValue
- the string valuelocale
- the locale to use while parsing- Gibt zurück:
- the value
- Löst aus:
NumberFormatException
- if the value could not be parsed
-
parseIntoNumber
Helper method to parse a number object out of a string- Parameter:
stringValue
- the string valuelocale
- the locale to use while parsing- Gibt zurück:
- the Number
- Löst aus:
NumberFormatException
- if the value could not be parsed
-
assertValidity
Determine whether a field meets the criteria specified in the constraints defined for this validator- Angegeben von:
assertValidity
in SchnittstelleValidator<T extends Number>
- Setzt außer Kraft:
assertValidity
in KlasseDefaultValidator<T extends Number>
- Parameter:
field
- aField
to be tested- Löst aus:
ValidationException
- containing an error message if the testValue did not pass the validation tests.
-
assertValidity
Determine whether a testValue meets the criteria specified in the constraints defined for this validator- Parameter:
testValue
- aString
to be testedlocale
- the Locale of the associated field- Löst aus:
ValidationException
- containing an error message if the testValue did not pass the validation tests.
-
getMinValueMessage
Get the value of minValueMessage.- Gibt zurück:
- value of minValueMessage.
-
setMinValueMessage
Set the value of minValueMessage.- Parameter:
minValueMessage
- Value to assign to minValueMessage.
-
getMaxValueMessage
Get the value of maxValueMessage.- Gibt zurück:
- value of maxValueMessage.
-
setMaxValueMessage
Set the value of maxValueMessage.- Parameter:
maxValueMessage
- Value to assign to maxValueMessage.
-
getInvalidNumberMessage
Get the value of invalidNumberMessage.- Gibt zurück:
- value of invalidNumberMessage.
-
setInvalidNumberMessage
Set the value of invalidNumberMessage.- Parameter:
invalidNumberMessage
- Value to assign to invalidNumberMessage.
-
getMinValue
Get the value of minValue.- Gibt zurück:
- value of minValue.
-
setMinValue
Set the value of minValue.- Parameter:
minValue
- Value to assign to minValue.
-
getMaxValue
Get the value of maxValue.- Gibt zurück:
- value of maxValue.
-
setMaxValue
Set the value of maxValue.- Parameter:
maxValue
- Value to assign to maxValue.
-