Class BigDecimalFormatter
java.lang.Object
org.eclipse.nebula.widgets.formattedtext.AbstractFormatter
org.eclipse.nebula.widgets.formattedtext.NumberFormatter
org.eclipse.nebula.widgets.formattedtext.BigDecimalFormatter
- All Implemented Interfaces:
java.util.EventListener,ITextFormatter,org.eclipse.swt.events.VerifyListener,org.eclipse.swt.internal.SWTEventListener
public class BigDecimalFormatter extends NumberFormatter
This class provides formatting of
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()).
-
Field Summary
Fields inherited from class org.eclipse.nebula.widgets.formattedtext.NumberFormatter
alwaysShowDec, cachedPatterns, decimalLen, editPattern, editValue, fixedDec, fixedInt, groupLen, intCount, intLen, locale, minus, modified, nbspSeparator, negative, nfDisplay, nfEdit, prefixLen, suffixLen, symbols, value, zeroDecimalLen, zeroIntLenFields inherited from class org.eclipse.nebula.widgets.formattedtext.AbstractFormatter
EMPTY, ignore, SPACE, text -
Constructor Summary
Constructors Constructor Description BigDecimalFormatter()Constructs a new instance with all defaults.BigDecimalFormatter(java.lang.String editPattern)Constructs a new instance with the given edit mask.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.BigDecimalFormatter(java.lang.String editPattern, java.util.Locale loc)Constructs a new instance with the given edit mask and locale.BigDecimalFormatter(java.util.Locale loc)Constructs a new instance with default edit and display masks for the given locale. -
Method Summary
Modifier and Type Method Description java.lang.ObjectgetValue()Returns the current value of the text control if it is a validBigDecimal.java.lang.Class<java.math.BigDecimal>getValueType()Returns the type of value thisITextFormatterhandles, i.e. returns ingetValue().
A BigDecimalFormatter always returns an BigDecimal value.protected voidsetPatterns(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.Methods inherited from class org.eclipse.nebula.widgets.formattedtext.NumberFormatter
clearText, format, getDefaultPattern, getDisplayString, getEditString, isEmpty, isValid, setDecimalSeparatorAlwaysShown, setFixedLengths, setPrefix, setSuffix, setValue, verifyTextMethods inherited from class org.eclipse.nebula.widgets.formattedtext.AbstractFormatter
beep, detach, setIgnore, setText, updateText, updateText
-
Constructor Details
-
BigDecimalFormatter
public BigDecimalFormatter()Constructs a new instance with all defaults.- See Also:
NumberFormatter()
-
BigDecimalFormatter
public BigDecimalFormatter(java.util.Locale loc)Constructs a new instance with default edit and display masks for the given locale.- Parameters:
loc- thelocale
-
BigDecimalFormatter
public BigDecimalFormatter(java.lang.String editPattern, java.util.Locale loc)Constructs a new instance with the given edit mask and locale. Display mask is identical to the edit mask.- Parameters:
editPattern- the edit maskloc- thelocale
-
BigDecimalFormatter
public BigDecimalFormatter(java.lang.String editPattern, java.lang.String displayPattern, java.util.Locale loc)Constructs a new instance with the given masks and locale.- Parameters:
editPattern- the edit maskdisplayPattern- the display maskloc- thelocale
-
BigDecimalFormatter
public BigDecimalFormatter(java.lang.String editPattern, java.lang.String displayPattern)Constructs a new instance with the given edit and display masks. Uses the default locale.- Parameters:
editPattern- the edit maskdisplayPattern- the display mask
-
BigDecimalFormatter
public BigDecimalFormatter(java.lang.String editPattern)Constructs a new instance with the given edit mask. Display mask is identical to the edit mask, and locale is the default one.- Parameters:
editPattern- the edit mask
-
-
Method Details
-
getValue
public java.lang.Object getValue()Returns the current value of the text control if it is a validBigDecimal. If the buffer is flagged as modified, the value is recalculated by parsing with thenfEditinitialized with the edit pattern. If the number is not valid, returnsnull.- Specified by:
getValuein interfaceITextFormatter- Overrides:
getValuein classNumberFormatter- Returns:
- current
BigDecimalvalue if valid, elsenull - See Also:
ITextFormatter.getValue()
-
getValueType
public java.lang.Class<java.math.BigDecimal> getValueType()Returns the type of value thisITextFormatterhandles, i.e. returns ingetValue().
A BigDecimalFormatter always returns an BigDecimal value.- Specified by:
getValueTypein interfaceITextFormatter- Overrides:
getValueTypein classNumberFormatter- Returns:
- The value type.
-
setPatterns
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.Override the NumberFormatter implementation to handle large numbers.
- Overrides:
setPatternsin classNumberFormatter- Parameters:
edit- edit patterndisplay- display patternloc- Locale to use- Throws:
java.lang.IllegalArgumentException- if a pattern is invalid- See Also:
com.wdev91.comp4swt.core.NumberFormatter#setPatterns(java.lang.String, java.lang.String, java.util.Locale)
-