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,- java.io.Serializable,- java.lang.Cloneable
 
 public class RMNumberFormat extends java.text.DecimalFormat implements RMFormat 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:
- Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description static RMNumberFormatBASICstatic RMNumberFormatCURRENCYstatic RMNumberFormatDOLLARSstatic RMNumberFormatPLAIN
 - 
Constructor SummaryConstructors Constructor Description RMNumberFormat()Creates an uninitialized number format.RMNumberFormat(RMNumberFormat aFormat)Creates a number format identical to the given format.RMNumberFormat(java.lang.String aFormatString)Creates a number format for the given format string.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.text.DecimalFormatSymbolscreateDecimalFormatSymbols()Creates new decimal format symbols.booleanequals(java.lang.Object anObj)Standard equals implementation.java.lang.ObjectformatRM(java.lang.Object anObj)Returns a formatted version of the given object.java.lang.ObjectfromXML(RXArchiver anArchiver, RXElement anElement)XML unarchival.java.lang.StringgetDecimalSeparator()Returns the decimal separator.static java.util.LocalegetDefaultLocale()Returns the default locale.java.lang.StringgetFormatString()Returns the format string for this format.java.lang.StringgetLocalCurrencySymbol()Returns the Currency symbol used for this locale.java.lang.StringgetNullString()Returns the String that is substituted when this format is asked to provide stringForObjectValue(null).java.lang.StringgetThousandsSeparator()Returns the thousands separator.booleanisCurrencySymbolUsed()Returns whether currency symbol is used (dollars, local or international).booleanisLocalCurrencySymbolUsed()Returns whether local currency symbol is used.booleanisNegativeInRed()Returns whether this format shows negative values in red.booleanisPercentSymbolUsed()Returns whether percent symbol is used.voidsetDecimalSeparator(java.lang.String aValue)Sets the decimal separator.static voidsetDefaultLocale(java.util.Locale aLocale)Sets the default locale.voidsetFormatString(java.lang.String aFormat)Sets the format string for this format.protected voidsetFormatStringSafe(java.lang.String aFormat)Used when deserializing, because we don't want an exception messing with opening the report.voidsetLocalCurrencySymbolUsed(boolean aFlag)Sets whether local currency symbol is used.voidsetNegativeInRed(boolean aFlag)Sets whether this format shows negative values in red.voidsetNullString(java.lang.String aString)Sets the String that is substituted when this format is asked to provide stringForObjectValue(null).voidsetPercentSymbolUsed(boolean aFlag)Returns whether percent symbol is used.voidsetThousandsSeparator(java.lang.String aValue)Sets the thousands separator.RXElementtoXML(RXArchiver anArchiver)XML archival.- 
Methods inherited from class java.text.DecimalFormatapplyLocalizedPattern, 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.NumberFormatformat, format, getAvailableLocales, getCurrencyInstance, getCurrencyInstance, getInstance, getInstance, getIntegerInstance, getIntegerInstance, getNumberInstance, getNumberInstance, getPercentInstance, getPercentInstance, isGroupingUsed, isParseIntegerOnly, parse, parseObject, setParseIntegerOnly
 
- 
 
- 
- 
- 
Field Detail- 
PLAINpublic static final RMNumberFormat PLAIN 
 - 
BASICpublic static final RMNumberFormat BASIC 
 - 
DOLLARSpublic static final RMNumberFormat DOLLARS 
 - 
CURRENCYpublic static final RMNumberFormat CURRENCY 
 
- 
 - 
Constructor Detail- 
RMNumberFormatpublic RMNumberFormat() Creates an uninitialized number format.
 - 
RMNumberFormatpublic RMNumberFormat(java.lang.String aFormatString) Creates a number format for the given format string.
 - 
RMNumberFormatpublic RMNumberFormat(RMNumberFormat aFormat) Creates a number format identical to the given format.
 
- 
 - 
Method Detail- 
createDecimalFormatSymbols@Nullable protected java.text.DecimalFormatSymbols createDecimalFormatSymbols() Creates new decimal format symbols.
 - 
getNullStringpublic java.lang.String getNullString() Returns the String that is substituted when this format is asked to provide stringForObjectValue(null).
 - 
setNullStringpublic void setNullString(java.lang.String aString) Sets the String that is substituted when this format is asked to provide stringForObjectValue(null).
 - 
isNegativeInRedpublic boolean isNegativeInRed() Returns whether this format shows negative values in red.
 - 
setNegativeInRedpublic void setNegativeInRed(boolean aFlag) Sets whether this format shows negative values in red.
 - 
getLocalCurrencySymbolpublic java.lang.String getLocalCurrencySymbol() Returns the Currency symbol used for this locale.
 - 
isLocalCurrencySymbolUsedpublic boolean isLocalCurrencySymbolUsed() Returns whether local currency symbol is used.
 - 
setLocalCurrencySymbolUsedpublic void setLocalCurrencySymbolUsed(boolean aFlag) Sets whether local currency symbol is used.
 - 
isCurrencySymbolUsedpublic boolean isCurrencySymbolUsed() Returns whether currency symbol is used (dollars, local or international).
 - 
isPercentSymbolUsedpublic boolean isPercentSymbolUsed() Returns whether percent symbol is used.
 - 
setPercentSymbolUsedpublic void setPercentSymbolUsed(boolean aFlag) Returns whether percent symbol is used.
 - 
getThousandsSeparatorpublic java.lang.String getThousandsSeparator() Returns the thousands separator.
 - 
setThousandsSeparatorpublic void setThousandsSeparator(java.lang.String aValue) Sets the thousands separator.
 - 
getDecimalSeparatorpublic java.lang.String getDecimalSeparator() Returns the decimal separator.
 - 
setDecimalSeparatorpublic void setDecimalSeparator(java.lang.String aValue) Sets the decimal separator.
 - 
getFormatStringpublic java.lang.String 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:
- getFormatStringin interface- RMFormat
 
 - 
setFormatStringpublic void setFormatString(@Nonnull java.lang.String aFormat)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:
- setFormatStringin interface- RMFormat
 
 - 
setFormatStringSafeprotected void setFormatStringSafe(@Nonnull java.lang.String aFormat)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@Nullable public java.lang.Object formatRM(java.lang.Object anObj) Returns a formatted version of the given object.
 - 
getDefaultLocalepublic static java.util.Locale getDefaultLocale() Returns the default locale.
 - 
setDefaultLocalepublic static void setDefaultLocale(java.util.Locale aLocale) Sets the default locale.
 - 
equalspublic boolean equals(java.lang.Object anObj) Standard equals implementation.- Overrides:
- equalsin class- java.text.DecimalFormat
 
 - 
toXMLpublic RXElement toXML(RXArchiver anArchiver) XML archival.- Specified by:
- toXMLin interface- Archivable
 
 - 
fromXMLpublic java.lang.Object fromXML(RXArchiver anArchiver, RXElement anElement) XML unarchival.- Specified by:
- fromXMLin interface- Archivable
 
 
- 
 
-