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, requiredMessageVon 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 TypMethodeBeschreibungvoidassertValidity(String testValue, Locale locale) Determine whether a testValue meets the criteria specified in the constraints defined for this validatorvoidassertValidity(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.voidinit(Map<String, ? extends Constraint> paramMap) Extract the relevant parameters from the constraints listed in <rule> tags within the intake.xml file.protected NumberparseIntoNumber(String stringValue, Locale locale) Helper method to parse a number object out of a stringprotected abstract TparseNumber(String stringValue, Locale locale) Parse the actual value out of a stringvoidsetInvalidNumberMessage(String invalidNumberMessage) Set the value of invalidNumberMessage.voidsetMaxValue(T maxValue) Set the value of maxValue.voidsetMaxValueMessage(String maxValueMessage) Set the value of maxValueMessage.voidsetMinValue(T minValue) Set the value of minValue.voidsetMinValueMessage(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:
initin SchnittstelleInitableByConstraintMap- Setzt außer Kraft:
initin KlasseDefaultValidator<T extends Number>- Parameter:
paramMap- aMapofrule'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:
assertValidityin SchnittstelleValidator<T extends Number>- Setzt außer Kraft:
assertValidityin KlasseDefaultValidator<T extends Number>- Parameter:
field- aFieldto 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- aStringto 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.
-