Package com.inductiveautomation.rm.base
Class RMNumberFormat
java.lang.Object
java.text.Format
java.text.NumberFormat
java.text.DecimalFormat
com.inductiveautomation.rm.base.RMNumberFormat
- All Implemented Interfaces:
Archivable
,RMFormat
,Serializable
,Cloneable
This subclass extends DecimalFormat to implement ReportMill's RMFormat interface and to support the extended features
"Negative in Red" and "Null String". It also has a toPattern like method, getFormatString, for the purposes of
archival.
Also, our modified pattern format can be ambiguous if either decimal or grouping separator not included. In this case we assume any separator preceded by a '0' is the decimal separator. This seems reasonable since a decimal separator preceded by # could result in an empty string or a fractional number with no leading zero (like ".123" instead of "0.123") which seems somewhat rare. And also a grouping separator preceded by 0 seems somewhat rare because it could result in a long zero string like "0,000".
I suppose we should instead have a syntax explicitly declaring decimal and group separators: "$ #,##0.00;ds=,;gs=.".
Removed arbitrary decimal and grouping separators in 7.8.1
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.text.NumberFormat
NumberFormat.Field, NumberFormat.Style
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final RMNumberFormat
static final RMNumberFormat
static final RMNumberFormat
static final RMNumberFormat
Fields inherited from class java.text.NumberFormat
FRACTION_FIELD, INTEGER_FIELD
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an uninitialized number format.RMNumberFormat
(RMNumberFormat aFormat) Creates a number format identical to the given format.RMNumberFormat
(String aFormatString) Creates a number format for the given format string. -
Method Summary
Modifier and TypeMethodDescriptionprotected DecimalFormatSymbols
Creates new decimal format symbols.boolean
Standard equals implementation.Returns a formatted version of the given object.fromXML
(RXArchiver anArchiver, RXElement anElement) XML unarchival.Returns the decimal separator.static Locale
Returns the default locale.Returns the format string for this format.Returns the Currency symbol used for this locale.Returns the String that is substituted when this format is asked to provide stringForObjectValue(null).Returns the thousands separator.boolean
Returns whether currency symbol is used (dollars, local or international).boolean
Returns whether local currency symbol is used.boolean
Returns whether this format shows negative values in red.boolean
Returns whether percent symbol is used.void
setDecimalSeparator
(String aValue) Sets the decimal separator.static void
setDefaultLocale
(Locale aLocale) Sets the default locale.void
setFormatString
(String aFormat) Sets the format string for this format.protected void
setFormatStringSafe
(String aFormat) Used when deserializing, because we don't want an exception messing with opening the report.void
setLocalCurrencySymbolUsed
(boolean aFlag) Sets whether local currency symbol is used.void
setNegativeInRed
(boolean aFlag) Sets whether this format shows negative values in red.void
setNullString
(String aString) Sets the String that is substituted when this format is asked to provide stringForObjectValue(null).void
setPercentSymbolUsed
(boolean aFlag) Returns whether percent symbol is used.void
setThousandsSeparator
(String aValue) Sets the thousands separator.toXML
(RXArchiver anArchiver) XML archival.Methods inherited from class java.text.DecimalFormat
applyLocalizedPattern, applyPattern, clone, format, format, format, formatToCharacterIterator, getCurrency, getDecimalFormatSymbols, getGroupingSize, getMaximumFractionDigits, getMaximumIntegerDigits, getMinimumFractionDigits, getMinimumIntegerDigits, getMultiplier, getNegativePrefix, getNegativeSuffix, getPositivePrefix, getPositiveSuffix, getRoundingMode, hashCode, isDecimalSeparatorAlwaysShown, isParseBigDecimal, parse, setCurrency, setDecimalFormatSymbols, setDecimalSeparatorAlwaysShown, setGroupingSize, setGroupingUsed, setMaximumFractionDigits, setMaximumIntegerDigits, setMinimumFractionDigits, setMinimumIntegerDigits, setMultiplier, setNegativePrefix, setNegativeSuffix, setParseBigDecimal, setPositivePrefix, setPositiveSuffix, setRoundingMode, toLocalizedPattern, toPattern
Methods inherited from class java.text.NumberFormat
format, format, getAvailableLocales, getCompactNumberInstance, getCompactNumberInstance, getCurrencyInstance, getCurrencyInstance, getInstance, getInstance, getIntegerInstance, getIntegerInstance, getNumberInstance, getNumberInstance, getPercentInstance, getPercentInstance, isGroupingUsed, isParseIntegerOnly, parse, parseObject, setParseIntegerOnly
Methods inherited from class java.text.Format
format, parseObject
-
Field Details
-
PLAIN
-
BASIC
-
DOLLARS
-
CURRENCY
-
-
Constructor Details
-
RMNumberFormat
public RMNumberFormat()Creates an uninitialized number format. -
RMNumberFormat
Creates a number format for the given format string. -
RMNumberFormat
Creates a number format identical to the given format.
-
-
Method Details
-
createDecimalFormatSymbols
Creates new decimal format symbols. -
getNullString
Returns the String that is substituted when this format is asked to provide stringForObjectValue(null). -
setNullString
Sets the String that is substituted when this format is asked to provide stringForObjectValue(null). -
isNegativeInRed
public boolean isNegativeInRed()Returns whether this format shows negative values in red. -
setNegativeInRed
public void setNegativeInRed(boolean aFlag) Sets whether this format shows negative values in red. -
getLocalCurrencySymbol
Returns the Currency symbol used for this locale. -
isLocalCurrencySymbolUsed
public boolean isLocalCurrencySymbolUsed()Returns whether local currency symbol is used. -
setLocalCurrencySymbolUsed
public void setLocalCurrencySymbolUsed(boolean aFlag) Sets whether local currency symbol is used. -
isCurrencySymbolUsed
public boolean isCurrencySymbolUsed()Returns whether currency symbol is used (dollars, local or international). -
isPercentSymbolUsed
public boolean isPercentSymbolUsed()Returns whether percent symbol is used. -
setPercentSymbolUsed
public void setPercentSymbolUsed(boolean aFlag) Returns whether percent symbol is used. -
getThousandsSeparator
Returns the thousands separator. -
setThousandsSeparator
Sets the thousands separator. -
getDecimalSeparator
Returns the decimal separator. -
setDecimalSeparator
Sets the decimal separator. -
getFormatString
Returns the format string for this format. This is basically the default toPattern() of DecimalFormat, except that it allows for a arbitrary decimal and grouping separators. Ability to set arbitrary decimal and grouping separators removed in 7.8.1, but left this intact in case someone set them in 7.8.0. And then removed altogether in 7.8.2, because it plays havoc in non-English locales. If users need a whacky formatting, they need to do it themselves in scripting.- Specified by:
getFormatString
in interfaceRMFormat
-
setFormatString
Sets the format string for this format. This is basically the default applyPattern() of DecimalFormat. Removed ability to set arbitrary decimal and grouping separators in 7.8.1, in favor of compatibility with rest of ignition.- Specified by:
setFormatString
in interfaceRMFormat
-
setFormatStringSafe
Used when deserializing, because we don't want an exception messing with opening the report. We'll prevent users from setting a bad string themselves with setFormatString -
formatRM
Returns a formatted version of the given object. -
getDefaultLocale
Returns the default locale. -
setDefaultLocale
Sets the default locale. -
equals
Standard equals implementation.- Overrides:
equals
in classDecimalFormat
-
toXML
XML archival.- Specified by:
toXML
in interfaceArchivable
-
fromXML
XML unarchival.- Specified by:
fromXML
in interfaceArchivable
-