public class NumericFormElementConfiguration extends HashMap<String,Object>
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.Modifier and Type | Class and Description |
---|---|
static class |
NumericFormElementConfiguration.Format
Predefined formats defining decimal spaces, rounding methods, negative formatters and optionally a sign.
|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Modifier and Type | Field and Description |
---|---|
static String |
EMPTY_EMPTY |
static String |
EMPTY_SIGN |
static String |
EMPTY_ZERO |
static String |
NEGATIVE_ANGLES |
static String |
NEGATIVE_BRACES |
static String |
NEGATIVE_BRACKETS |
static String |
NEGATIVE_PARENTHESES |
static String |
ROUND_CEILING |
static String |
ROUND_DOWN |
static String |
ROUND_FLOOR |
static String |
ROUND_HALF_DOWN_ASYMMETRIC |
static String |
ROUND_HALF_DOWN_SYMMETRIC |
static String |
ROUND_HALF_EVEN |
static String |
ROUND_HALF_UP_ASYMMETRIC |
static String |
ROUND_HALF_UP_SYMMETRIC |
static String |
ROUND_SWISS |
static String |
ROUND_UP |
Constructor and Description |
---|
NumericFormElementConfiguration() |
NumericFormElementConfiguration(Currency currency) |
NumericFormElementConfiguration(Locale locale) |
NumericFormElementConfiguration(NumericFormElementConfiguration.Format format) |
NumericFormElementConfiguration(NumericFormElementConfiguration configuration) |
Modifier and Type | Method and Description |
---|---|
NumberFormat |
createNumberFormat()
Create a
NumberFormat that represents the same configuration. |
static NumericFormElementConfiguration |
currency(Currency currency,
int decimalPositions,
boolean forceWhitespaceAroundSign)
Create a localizable configuration for a given currency.
|
Currency |
getCurrency() |
NumericFormElementConfiguration.Format |
getFormat() |
int |
getMultiplier() |
boolean |
isForceWhitespaceAroundSign() |
boolean |
isLocalizeDecimalSymbols() |
boolean |
isLocalizeOutputFormat() |
NumericFormElementConfiguration |
localize(Locale locale)
Create a localized version of this configuration.
|
static NumericFormElementConfiguration |
percent(int decimalPositions,
boolean forceWhitespaceAroundSign)
Create a localizable configuration for percentages.
|
Object |
put(String key,
Object value) |
void |
setCurrency(Currency currency) |
void |
setCurrency(Currency currency,
Locale locale)
Set currency to use and locale for which to retrieve the currency signal.
|
void |
setDecimalPadding(boolean padding) |
void |
setDecimalPositions(int positions) |
void |
setDecimalSeparator(char separator) |
void |
setEmptyBehaviour(String behaviour) |
void |
setForceWhitespaceAroundSign(boolean forceWhitespaceAroundSign)
Ensure that whitespace is added between the sign and the number itself, no matter the localized format.
|
void |
setFormat(NumericFormElementConfiguration.Format format) |
void |
setGroupingSeparator(Character separator) |
void |
setGroupingSize(int size) |
void |
setLocalizeDecimalSymbols(boolean localizeDecimalSymbols)
Set to
true if you want to have the decimal symbols modified when calling localize(Locale) . |
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. |
void |
setMaxValue(Number maxValue) |
void |
setMinValue(Number minValue) |
void |
setMultiplier(int multiplier)
Set the multiplier to apply to the value before formatting and when posting back.
|
void |
setNegativeFormatter(String formatter)
Set the format to be used when rendering negative values if the texbox is not in focus.
|
void |
setRoundingMode(RoundingMode roundingMode) |
void |
setRoundingMode(String mode) |
void |
setSign(String sign) |
void |
setSignPositionRight(boolean positionRight) |
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
equals, hashCode, toString
public static final String ROUND_HALF_UP_SYMMETRIC
public static final String ROUND_HALF_UP_ASYMMETRIC
public static final String ROUND_HALF_DOWN_SYMMETRIC
public static final String ROUND_HALF_DOWN_ASYMMETRIC
public static final String ROUND_HALF_EVEN
public static final String ROUND_UP
public static final String ROUND_DOWN
public static final String ROUND_CEILING
public static final String ROUND_FLOOR
public static final String ROUND_SWISS
public static final String NEGATIVE_PARENTHESES
public static final String NEGATIVE_BRACKETS
public static final String NEGATIVE_BRACES
public static final String NEGATIVE_ANGLES
public static final String EMPTY_EMPTY
public static final String EMPTY_ZERO
public static final String EMPTY_SIGN
public NumericFormElementConfiguration()
public NumericFormElementConfiguration(NumericFormElementConfiguration.Format format)
public NumericFormElementConfiguration(Currency currency)
public NumericFormElementConfiguration(Locale locale)
public NumericFormElementConfiguration(NumericFormElementConfiguration configuration)
public NumericFormElementConfiguration.Format getFormat()
public void setFormat(NumericFormElementConfiguration.Format format)
public void setCurrency(Currency currency)
public void setCurrency(Currency currency, Locale locale)
currency
- instancelocale
- to use the currency symbol frompublic Currency getCurrency()
public void setDecimalPositions(int positions)
public void setGroupingSeparator(Character separator)
public void setGroupingSize(int size)
public void setDecimalSeparator(char separator)
public void setSign(String sign)
public void setSignPositionRight(boolean positionRight)
public void setMinValue(Number minValue)
public void setMaxValue(Number maxValue)
public void setRoundingMode(RoundingMode roundingMode)
public void setMultiplier(int multiplier)
multiplier
- defaults to 1public int getMultiplier()
public void setRoundingMode(String mode)
public void setDecimalPadding(boolean padding)
public void setNegativeFormatter(String formatter)
NEGATIVE_BRACES
.formatter
- stringpublic void setEmptyBehaviour(String behaviour)
public boolean isLocalizeOutputFormat()
public void setLocalizeOutputFormat(boolean localizeOutputFormat)
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
.localizeOutputFormat
- true if parameters can be modified according to output localepublic boolean isLocalizeDecimalSymbols()
public void setLocalizeDecimalSymbols(boolean localizeDecimalSymbols)
true
if you want to have the decimal symbols modified when calling localize(Locale)
.localizeDecimalSymbols
- true if decimal symbols should be gotten from the localepublic boolean isForceWhitespaceAroundSign()
public void setForceWhitespaceAroundSign(boolean forceWhitespaceAroundSign)
forceWhitespaceAroundSign
- true if space will be introducedpublic 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.
locale
- instanceisLocalizeOutputFormat()
is true
public NumberFormat createNumberFormat()
NumberFormat
that represents the same configuration.public static NumericFormElementConfiguration percent(int decimalPositions, boolean forceWhitespaceAroundSign)
decimalPositions
- number of decimal positions to showforceWhitespaceAroundSign
- true if whitespace should be added around the sign independent of the localepublic static NumericFormElementConfiguration currency(Currency currency, int decimalPositions, boolean forceWhitespaceAroundSign)
currency
- currency to usedecimalPositions
- number of decimal positions to showforceWhitespaceAroundSign
- true if whitespace should be added around the sign independent of the localeCopyright © 2018. All rights reserved.