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>
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumPredefined formats defining decimal spaces, rounding methods, negative formatters and optionally a sign.Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
ConstructorsConstructorDescriptionNumericFormElementConfiguration(NumericFormElementConfiguration configuration) NumericFormElementConfiguration(Currency currency) -
Method Summary
Modifier and TypeMethodDescriptionCreate aNumberFormatthat represents the same configuration.Create a localizable configuration for a given currency.intbooleanbooleanbooleanCreate a localized version of this configuration.percent(int decimalPositions, boolean forceWhitespaceAroundSign) Create a localizable configuration for percentages.voidsetCurrency(Currency currency) voidsetCurrency(Currency currency, Locale locale) Set currency to use and locale for which to retrieve the currency signal.voidsetDecimalPadding(boolean padding) voidsetDecimalPositions(int positions) voidsetDecimalSeparator(char separator) voidsetEmptyBehaviour(String behaviour) voidsetForceWhitespaceAroundSign(boolean forceWhitespaceAroundSign) Ensure that whitespace is added between the sign and the number itself, no matter the localized format.voidvoidsetGroupingSeparator(Character separator) voidsetGroupingSize(int size) voidsetLocalizeDecimalSymbols(boolean localizeDecimalSymbols) Set totrueif you want to have the decimal symbols modified when callinglocalize(Locale).voidsetLocalizeOutputFormat(boolean localizeOutputFormat) Set totrueif 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.voidsetMaxValue(Number maxValue) voidsetMinValue(Number minValue) voidsetMultiplier(int multiplier) Set the multiplier to apply to the value before formatting and when posting back.voidsetNegativeFormatter(String formatter) Set the format to be used when rendering negative values if the texbox is not in focus.voidsetRoundingMode(String mode) voidsetRoundingMode(RoundingMode roundingMode) voidvoidsetSignPositionRight(boolean positionRight) Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesMethods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Field Details
-
ROUND_HALF_UP_SYMMETRIC
- See Also:
-
ROUND_HALF_UP_ASYMMETRIC
- See Also:
-
ROUND_HALF_DOWN_SYMMETRIC
- See Also:
-
ROUND_HALF_DOWN_ASYMMETRIC
- See Also:
-
ROUND_HALF_EVEN
- See Also:
-
ROUND_UP
- See Also:
-
ROUND_DOWN
- See Also:
-
ROUND_CEILING
- See Also:
-
ROUND_FLOOR
- See Also:
-
ROUND_SWISS
- See Also:
-
NEGATIVE_PARENTHESES
- See Also:
-
NEGATIVE_BRACKETS
- See Also:
-
NEGATIVE_BRACES
- See Also:
-
NEGATIVE_ANGLES
- See Also:
-
EMPTY_EMPTY
- See Also:
-
EMPTY_ZERO
- See Also:
-
EMPTY_SIGN
- See Also:
-
-
Constructor Details
-
NumericFormElementConfiguration
public NumericFormElementConfiguration() -
NumericFormElementConfiguration
-
NumericFormElementConfiguration
-
NumericFormElementConfiguration
-
NumericFormElementConfiguration
-
-
Method Details
-
getFormat
-
setFormat
-
setCurrency
-
setCurrency
Set currency to use and locale for which to retrieve the currency signal.- Parameters:
currency- instancelocale- to use the currency symbol from
-
getCurrency
-
setDecimalPositions
public void setDecimalPositions(int positions) -
setGroupingSeparator
-
setGroupingSize
public void setGroupingSize(int size) -
setDecimalSeparator
public void setDecimalSeparator(char separator) -
setSign
-
setSignPositionRight
public void setSignPositionRight(boolean positionRight) -
setMinValue
-
setMaxValue
-
setRoundingMode
-
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
-
setDecimalPadding
public void setDecimalPadding(boolean padding) -
setNegativeFormatter
Set the format to be used when rendering negative values if the texbox is not in focus. See for exampleNEGATIVE_BRACES.- Parameters:
formatter- string
-
setEmptyBehaviour
-
isLocalizeOutputFormat
public boolean isLocalizeOutputFormat() -
setLocalizeOutputFormat
public void setLocalizeOutputFormat(boolean localizeOutputFormat) Set totrueif 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 istrue.- Parameters:
localizeOutputFormat- true if parameters can be modified according to output locale
-
isLocalizeDecimalSymbols
public boolean isLocalizeDecimalSymbols() -
setLocalizeDecimalSymbols
public void setLocalizeDecimalSymbols(boolean localizeDecimalSymbols) Set totrueif you want to have the decimal symbols modified when callinglocalize(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
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()andisLocalizeDecimalSymbols()will determine which settings this method will modify.- Parameters:
locale- instance- Returns:
- clone with altered settings if
isLocalizeOutputFormat()istrue
-
put
-
createNumberFormat
Create aNumberFormatthat 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 showforceWhitespaceAroundSign- 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 usedecimalPositions- number of decimal positions to showforceWhitespaceAroundSign- true if whitespace should be added around the sign independent of the locale- Returns:
- configuration
-