public class BigDecimalFormatter extends NumberFormatter
BigDecimal
values in a FormattedText
.
BigDecimalFormatter returns different numeric types based on the current
value in the Text field. BigDecimalFormatter is an override of NumberFormatter
allowing to guaranty to always return BigDecimal
values (Object.toString()
).
alwaysShowDec, cachedPatterns, decimalLen, editPattern, editValue, fixedDec, fixedInt, groupLen, intCount, intLen, locale, minus, modified, nbspSeparator, negative, nfDisplay, nfEdit, prefixLen, suffixLen, symbols, value, zeroDecimalLen, zeroIntLen
EMPTY, ignore, SPACE, text
Constructor and Description |
---|
BigDecimalFormatter()
Constructs a new instance with all defaults.
|
BigDecimalFormatter(java.util.Locale loc)
Constructs a new instance with default edit and display masks for the given
locale.
|
BigDecimalFormatter(java.lang.String editPattern)
Constructs a new instance with the given edit mask.
|
BigDecimalFormatter(java.lang.String editPattern,
java.util.Locale loc)
Constructs a new instance with the given edit mask and locale.
|
BigDecimalFormatter(java.lang.String editPattern,
java.lang.String displayPattern)
Constructs a new instance with the given edit and display masks.
|
BigDecimalFormatter(java.lang.String editPattern,
java.lang.String displayPattern,
java.util.Locale loc)
Constructs a new instance with the given masks and locale.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getValue()
Returns the current value of the text control if it is a valid
BigDecimal . |
java.lang.Class<java.math.BigDecimal> |
getValueType()
Returns the type of value this
ITextFormatter handles,
i.e. |
protected void |
setPatterns(java.lang.String edit,
java.lang.String display,
java.util.Locale loc)
Sets the patterns and initializes the technical attributes used to manage
the operations.
|
clearText, format, getDefaultPattern, getDisplayString, getEditString, isEmpty, isValid, setDecimalSeparatorAlwaysShown, setFixedLengths, setPrefix, setSuffix, setValue, verifyText
beep, detach, setIgnore, setText, updateText, updateText
public BigDecimalFormatter()
NumberFormatter.NumberFormatter()
public BigDecimalFormatter(java.util.Locale loc)
loc
- the locale
public BigDecimalFormatter(java.lang.String editPattern, java.util.Locale loc)
editPattern
- the edit maskloc
- the locale
public BigDecimalFormatter(java.lang.String editPattern, java.lang.String displayPattern, java.util.Locale loc)
editPattern
- the edit maskdisplayPattern
- the display maskloc
- the locale
public BigDecimalFormatter(java.lang.String editPattern, java.lang.String displayPattern)
editPattern
- the edit maskdisplayPattern
- the display maskpublic BigDecimalFormatter(java.lang.String editPattern)
editPattern
- the edit maskpublic java.lang.Object getValue()
BigDecimal
.
If the buffer is flagged as modified, the value is recalculated by parsing
with the nfEdit
initialized with the edit pattern. If the
number is not valid, returns null
.getValue
in interface ITextFormatter
getValue
in class NumberFormatter
BigDecimal
value if valid, else null
ITextFormatter.getValue()
public java.lang.Class<java.math.BigDecimal> getValueType()
ITextFormatter
handles,
i.e. returns in getValue()
.getValueType
in interface ITextFormatter
getValueType
in class NumberFormatter
protected void setPatterns(java.lang.String edit, java.lang.String display, java.util.Locale loc)
Override the NumberFormatter implementation to handle large numbers.
setPatterns
in class NumberFormatter
edit
- edit patterndisplay
- display patternloc
- Locale to usejava.lang.IllegalArgumentException
- if a pattern is invalidcom.wdev91.comp4swt.core.NumberFormatter#setPatterns(java.lang.String, java.lang.String, java.util.Locale)