Class NumericCheckerImpl
java.lang.Object
de.hybris.platform.sap.productconfig.frontend.validator.impl.NumericCheckerImpl
- All Implemented Interfaces:
CsticValueValidator
Validates user input for numeric fields, considering the current locale. typical checks are:
- if input contains a number at all
- number of digits and fraction digits does not exceed the maximum allowed for corresponding field
- proper use of grouping and decimal separator
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanbooleanbooleanprotected voidcheckLength(BigDecimal numberToCheck, String value, CsticData cstic, org.springframework.validation.Errors errorObj, Locale locale) protected intcountDecimals(BigDecimal numberToCheck) protected StringcreateExpectedFormatAsString(int maxIntegerPlaces, int maxDecimalPlaces, Locale locale) protected voidcreateFieldError(CsticData cstic, String errorValue, org.springframework.validation.Errors errorObj, Object[] args, String defaultMsg, String msgKey) protected StringBuildercreateTemplateForDecimals(int maxIntegerPlaces, char groupingSeparator) protected StringcreateTemplateForFractions(int maxDecimalPlaces, char decimalSeparator) protected I18NServiceprotected booleanisNegativeNumberAllowed(String entryFieldMask) voidsetI18NService(I18NService i18nService) Validates the value of the cstic.protected booleanvalidateValue(String value, DecimalFormatSymbols symbols)
-
Field Details
-
NUMBER_OF_CHARS_FOR_THOUSANDS_GROUPING
public static final int NUMBER_OF_CHARS_FOR_THOUSANDS_GROUPING- See Also:
-
-
Constructor Details
-
NumericCheckerImpl
public NumericCheckerImpl()
-
-
Method Details
-
validate
public String validate(CsticData cstic, org.springframework.validation.Errors errorObj, String value) Description copied from interface:CsticValueValidatorValidates the value of the cstic.- Specified by:
validatein interfaceCsticValueValidator- Parameters:
cstic- to access any meta data for validationerrorObj- to add errors if foundvalue- actual value to check- Returns:
- modified value, or
nullif no value modification is required
-
validateValue
-
isNegativeNumberAllowed
-
checkLength
protected void checkLength(BigDecimal numberToCheck, String value, CsticData cstic, org.springframework.validation.Errors errorObj, Locale locale) -
createFieldError
-
createExpectedFormatAsString
-
createTemplateForFractions
-
createTemplateForDecimals
-
countDecimals
-
getI18NService
-
setI18NService
- Parameters:
i18nService- injects the i18nService from which the current locale will be obtained
-
appliesTo
- Specified by:
appliesToin interfaceCsticValueValidator- Returns:
trueonly if this validator is apllicable to this cstic
-
appliesToValues
public boolean appliesToValues()- Specified by:
appliesToValuesin interfaceCsticValueValidator- Returns:
trueonly if this validator is apllicable to this cstic values
-
appliesToFormattedValues
public boolean appliesToFormattedValues()- Specified by:
appliesToFormattedValuesin interfaceCsticValueValidator- Returns:
trueonly if this validator is apllicable to formatted cstic values
-
appliesToAdditionalValues
public boolean appliesToAdditionalValues()- Specified by:
appliesToAdditionalValuesin interfaceCsticValueValidator- Returns:
trueonly if this validator is apllicable to additional cstic values
-