Class ShortFormatter
java.lang.Object
org.eclipse.nebula.widgets.formattedtext.AbstractFormatter
org.eclipse.nebula.widgets.formattedtext.NumberFormatter
org.eclipse.nebula.widgets.formattedtext.ShortFormatter
- All Implemented Interfaces:
java.util.EventListener,ITextFormatter,org.eclipse.swt.events.VerifyListener,org.eclipse.swt.internal.SWTEventListener
public class ShortFormatter extends NumberFormatter
This class provides formatting of
Short values in a FormattedText.
ShortFormatter returns different numeric types based on the current
value in the Text field. ShortFormatter is an override of NumberFormatter
allowing to guaranty to always return Short values (Number.shortValue()).
-
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 ShortFormatter()Constructs a new instance with all defaults.ShortFormatter(java.lang.String editPattern)Constructs a new instance with the given edit mask.ShortFormatter(java.lang.String editPattern, java.lang.String displayPattern)Constructs a new instance with the given edit and display masks.ShortFormatter(java.lang.String editPattern, java.lang.String displayPattern, java.util.Locale loc)Constructs a new instance with the given masks and locale.ShortFormatter(java.lang.String editPattern, java.util.Locale loc)Constructs a new instance with the given edit mask and locale.ShortFormatter(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 validShort.java.lang.Class<java.lang.Short>getValueType()Returns the type of value thisITextFormatterhandles, i.e. returns ingetValue().
A ShortFormatter always returns an Short value.Methods inherited from class org.eclipse.nebula.widgets.formattedtext.NumberFormatter
clearText, format, getDefaultPattern, getDisplayString, getEditString, isEmpty, isValid, setDecimalSeparatorAlwaysShown, setFixedLengths, setPatterns, setPrefix, setSuffix, setValue, verifyTextMethods inherited from class org.eclipse.nebula.widgets.formattedtext.AbstractFormatter
beep, detach, setIgnore, setText, updateText, updateText
-
Constructor Details
-
ShortFormatter
public ShortFormatter()Constructs a new instance with all defaults.- See Also:
NumberFormatter()
-
ShortFormatter
public ShortFormatter(java.util.Locale loc)Constructs a new instance with default edit and display masks for the given locale.- Parameters:
loc- thelocale
-
ShortFormatter
public ShortFormatter(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
-
ShortFormatter
public ShortFormatter(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
-
ShortFormatter
public ShortFormatter(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
-
ShortFormatter
public ShortFormatter(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 validShort. 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
Shortvalue if valid, elsenull - See Also:
ITextFormatter.getValue()
-
getValueType
public java.lang.Class<java.lang.Short> getValueType()Returns the type of value thisITextFormatterhandles, i.e. returns ingetValue().
A ShortFormatter always returns an Short value.- Specified by:
getValueTypein interfaceITextFormatter- Overrides:
getValueTypein classNumberFormatter- Returns:
- The value type.
-