java.lang.Object
de.hybris.platform.sap.productconfig.frontend.validator.impl.NumericCheckerImpl
All Implemented Interfaces:
CsticValueValidator

public class NumericCheckerImpl extends Object implements 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 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: CsticValueValidator
      Validates the value of the cstic.
      Specified by:
      validate in interface CsticValueValidator
      Parameters:
      cstic - to access any meta data for validation
      errorObj - to add errors if found
      value - actual value to check
      Returns:
      modified value, or null if no value modification is required
    • validateValue

      protected boolean validateValue(String value, DecimalFormatSymbols symbols)
    • isNegativeNumberAllowed

      protected boolean isNegativeNumberAllowed(String entryFieldMask)
    • checkLength

      protected void checkLength(BigDecimal numberToCheck, String value, CsticData cstic, org.springframework.validation.Errors errorObj, Locale locale)
    • createFieldError

      protected void createFieldError(CsticData cstic, String errorValue, org.springframework.validation.Errors errorObj, Object[] args, String defaultMsg, String msgKey)
    • createExpectedFormatAsString

      protected String createExpectedFormatAsString(int maxIntegerPlaces, int maxDecimalPlaces, Locale locale)
    • createTemplateForFractions

      protected String createTemplateForFractions(int maxDecimalPlaces, char decimalSeparator)
    • createTemplateForDecimals

      protected StringBuilder createTemplateForDecimals(int maxIntegerPlaces, char groupingSeparator)
    • countDecimals

      protected int countDecimals(BigDecimal numberToCheck)
    • getI18NService

      protected I18NService getI18NService()
    • setI18NService

      public void setI18NService(I18NService i18nService)
      Parameters:
      i18nService - injects the i18nService from which the current locale will be obtained
    • appliesTo

      public boolean appliesTo(CsticData cstic)
      Specified by:
      appliesTo in interface CsticValueValidator
      Returns:
      true only if this validator is apllicable to this cstic
    • appliesToValues

      public boolean appliesToValues()
      Specified by:
      appliesToValues in interface CsticValueValidator
      Returns:
      true only if this validator is apllicable to this cstic values
    • appliesToFormattedValues

      public boolean appliesToFormattedValues()
      Specified by:
      appliesToFormattedValues in interface CsticValueValidator
      Returns:
      true only if this validator is apllicable to formatted cstic values
    • appliesToAdditionalValues

      public boolean appliesToAdditionalValues()
      Specified by:
      appliesToAdditionalValues in interface CsticValueValidator
      Returns:
      true only if this validator is apllicable to additional cstic values