Class RMNumberFormat
- All Implemented Interfaces:
- RMArchiver.Archiving,- RMFormat,- Serializable,- Cloneable
Those getFormatString/setFormatString support arbitrary decimal and grouping separators. This may be dangerous since when people use the default English versions of those, I think they change depending on the default JVM Locale. Only dangerous if someone wants to generate English Separators from a foreign local, I guess.
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 preceeded 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=.".
- See Also:
- 
Nested Class SummaryNested classes/interfaces inherited from class java.text.NumberFormatNumberFormat.Field, NumberFormat.Style
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic RMNumberFormatstatic RMNumberFormatstatic RMNumberFormatFields inherited from class java.text.NumberFormatFRACTION_FIELD, INTEGER_FIELD
- 
Constructor SummaryConstructorsConstructorDescriptionCreates 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 SummaryModifier and TypeMethodDescriptionbooleanStandard equals implementation.Returns a formatted version of the given object.fromXML(RXArchiver anArchiver, RXElement anElement) XML unarchival.Returns the decimal separator.Returns the format string for this format.Returns the String that is substituted when this format is asked to provide stringForObjectValue(null).Returns the thousands separator.initWithArchiver(RMArchiver anArchiver) Legacy archival.booleanReturns whether this format shows negative values in red.voidsetDecimalSeparator(String aValue) Sets the decimal separator.voidsetFormatString(String aFormat) Sets the format string for this format.voidsetNegativeInRed(boolean aFlag) Sets whether this format shows negative values in red.voidsetNullString(String aString) Sets the String that is substituted when this format is asked to provide stringForObjectValue(null).voidsetThousandsSeparator(String aValue) Sets the thousands separator.toXML(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, toPatternMethods inherited from class java.text.NumberFormatformat, format, getAvailableLocales, getCompactNumberInstance, getCompactNumberInstance, getCurrencyInstance, getCurrencyInstance, getInstance, getInstance, getIntegerInstance, getIntegerInstance, getNumberInstance, getNumberInstance, getPercentInstance, getPercentInstance, isGroupingUsed, isParseIntegerOnly, parse, parseObject, setParseIntegerOnlyMethods inherited from class java.text.Formatformat, parseObject
- 
Field Details- 
PLAIN
- 
BASIC
- 
DOLLARS
 
- 
- 
Constructor Details- 
RMNumberFormatpublic RMNumberFormat()Creates an uninitialized number format.
- 
RMNumberFormatCreates a number format for the given format string.
- 
RMNumberFormatCreates a number format identical to the given format.
 
- 
- 
Method Details- 
getNullStringReturns the String that is substituted when this format is asked to provide stringForObjectValue(null).
- 
setNullStringSets 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.
- 
getThousandsSeparatorReturns the thousands separator.
- 
setThousandsSeparatorSets the thousands separator.
- 
getDecimalSeparatorReturns the decimal separator.
- 
setDecimalSeparatorSets the decimal separator.
- 
getFormatStringReturns 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.- Specified by:
- getFormatStringin interface- RMFormat
 
- 
setFormatStringSets the format string for this format. This is basically the default applyPattern() of DecimalFormat, except that it allows for arbitrary decimal and grouping separators.- Specified by:
- setFormatStringin interface- RMFormat
 
- 
formatRMReturns a formatted version of the given object.
- 
equalsStandard equals implementation.- Overrides:
- equalsin class- DecimalFormat
 
- 
toXMLXML archival.
- 
fromXMLXML unarchival.
- 
initWithArchiverLegacy archival.- Specified by:
- initWithArchiverin interface- RMArchiver.Archiving
 
 
-