Class NumericFormElementConfiguration

java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<String,Object>
com.foreach.across.modules.bootstrapui.elements.NumericFormElementConfiguration
All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>

public class NumericFormElementConfiguration extends HashMap<String,Object>
Configuration class for a NumericFormElement based on JQuery autoNumeric plugin. The order in which properties are set is important, as setting a format or currency will update several properties at once.
Author:
Arne Vandamme
See Also:
  • Field Details

  • Constructor Details

    • NumericFormElementConfiguration

      public NumericFormElementConfiguration()
    • NumericFormElementConfiguration

      public NumericFormElementConfiguration(NumericFormElementConfiguration.Format format)
    • NumericFormElementConfiguration

      public NumericFormElementConfiguration(Currency currency)
    • NumericFormElementConfiguration

      public NumericFormElementConfiguration(Locale locale)
    • NumericFormElementConfiguration

      public NumericFormElementConfiguration(NumericFormElementConfiguration configuration)
  • Method Details

    • getFormat

    • setFormat

      public void setFormat(NumericFormElementConfiguration.Format format)
    • setCurrency

      public void setCurrency(Currency currency)
    • setCurrency

      public void setCurrency(Currency currency, Locale locale)
      Set currency to use and locale for which to retrieve the currency signal.
      Parameters:
      currency - instance
      locale - to use the currency symbol from
    • getCurrency

      public Currency getCurrency()
    • setDecimalPositions

      public void setDecimalPositions(int positions)
    • setGroupingSeparator

      public void setGroupingSeparator(Character separator)
    • setGroupingSize

      public void setGroupingSize(int size)
    • setDecimalSeparator

      public void setDecimalSeparator(char separator)
    • setSign

      public void setSign(String sign)
    • setSignPositionRight

      public void setSignPositionRight(boolean positionRight)
    • setMinValue

      public void setMinValue(Number minValue)
    • setMaxValue

      public void setMaxValue(Number maxValue)
    • setRoundingMode

      public void setRoundingMode(RoundingMode roundingMode)
    • setMultiplier

      public void setMultiplier(int multiplier)
      Set the multiplier to apply to the value before formatting and when posting back. Useful if percentage values are below 1 as the javascript control expects them between 0 and 100.
      Parameters:
      multiplier - defaults to 1
    • getMultiplier

      public int getMultiplier()
    • setRoundingMode

      public void setRoundingMode(String mode)
    • setDecimalPadding

      public void setDecimalPadding(boolean padding)
    • setNegativeFormatter

      public void setNegativeFormatter(String formatter)
      Set the format to be used when rendering negative values if the texbox is not in focus. See for example NEGATIVE_BRACES.
      Parameters:
      formatter - string
    • setEmptyBehaviour

      public void setEmptyBehaviour(String behaviour)
    • isLocalizeOutputFormat

      public boolean isLocalizeOutputFormat()
    • setLocalizeOutputFormat

      public void setLocalizeOutputFormat(boolean localizeOutputFormat)
      Set to true if the output format for currency or percentage should be determined using the output locale, this could modify both position and symbol for both currency and percent. Default is true.
      Parameters:
      localizeOutputFormat - true if parameters can be modified according to output locale
    • isLocalizeDecimalSymbols

      public boolean isLocalizeDecimalSymbols()
    • setLocalizeDecimalSymbols

      public void setLocalizeDecimalSymbols(boolean localizeDecimalSymbols)
      Set to true if you want to have the decimal symbols modified when calling localize(Locale).
      Parameters:
      localizeDecimalSymbols - true if decimal symbols should be gotten from the locale
    • isForceWhitespaceAroundSign

      public boolean isForceWhitespaceAroundSign()
    • setForceWhitespaceAroundSign

      public void setForceWhitespaceAroundSign(boolean forceWhitespaceAroundSign)
      Ensure that whitespace is added between the sign and the number itself, no matter the localized format.
      Parameters:
      forceWhitespaceAroundSign - true if space will be introduced
    • localize

      public NumericFormElementConfiguration localize(Locale locale)

      Create a localized version of this configuration. Meaning that number formatting specifications (decimal symbol, thousands separator etc) will be used from the current locale.

      This is different from the NumericFormElementConfiguration(Locale) constructor as that one creates a configuration for the currency attached to the locale specified. Even though the currency could be USD, you usually still want to render in the output locale.

      Properties isLocalizeOutputFormat() and isLocalizeDecimalSymbols() will determine which settings this method will modify.

      Parameters:
      locale - instance
      Returns:
      clone with altered settings if isLocalizeOutputFormat() is true
    • put

      public Object put(String key, Object value)
      Specified by:
      put in interface Map<String,Object>
      Overrides:
      put in class HashMap<String,Object>
    • createNumberFormat

      public NumberFormat createNumberFormat()
      Create a NumberFormat that represents the same configuration.
      Returns:
      numberformat instance
    • percent

      public static NumericFormElementConfiguration percent(int decimalPositions, boolean forceWhitespaceAroundSign)
      Create a localizable configuration for percentages.
      Parameters:
      decimalPositions - number of decimal positions to show
      forceWhitespaceAroundSign - true if whitespace should be added around the sign independent of the locale
      Returns:
      configuration
    • currency

      public static NumericFormElementConfiguration currency(Currency currency, int decimalPositions, boolean forceWhitespaceAroundSign)
      Create a localizable configuration for a given currency.
      Parameters:
      currency - currency to use
      decimalPositions - number of decimal positions to show
      forceWhitespaceAroundSign - true if whitespace should be added around the sign independent of the locale
      Returns:
      configuration