public class RMNumberFormat extends java.text.DecimalFormat implements RMFormat, RMArchiver.Archiving
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=.".
| Modifier and Type | Field and Description |
|---|---|
static RMNumberFormat |
BASIC |
static RMNumberFormat |
DOLLARS |
static RMNumberFormat |
PLAIN |
| Constructor and 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.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object anObj)
Standard equals implementation.
|
java.lang.Object |
formatRM(java.lang.Object anObj)
Returns a formatted version of the given object.
|
java.lang.Object |
fromXML(RXArchiver anArchiver,
RXElement anElement)
XML unarchival.
|
java.lang.String |
getDecimalSeparator()
Returns the decimal separator.
|
java.lang.String |
getFormatString()
Returns the format string for this format.
|
java.lang.String |
getNullString()
Returns the String that is substituted when this format is asked to provide stringForObjectValue(null).
|
java.lang.String |
getThousandsSeparator()
Returns the thousands separator.
|
java.lang.Object |
initWithArchiver(RMArchiver anArchiver)
Legacy archival.
|
boolean |
isNegativeInRed()
Returns whether this format shows negative values in red.
|
void |
setDecimalSeparator(java.lang.String aValue)
Sets the decimal separator.
|
void |
setFormatString(java.lang.String aFormat)
Sets the format string for this format.
|
void |
setNegativeInRed(boolean aFlag)
Sets whether this format shows negative values in red.
|
void |
setNullString(java.lang.String aString)
Sets the String that is substituted when this format is asked to provide stringForObjectValue(null).
|
void |
setThousandsSeparator(java.lang.String aValue)
Sets the thousands separator.
|
RXElement |
toXML(RXArchiver anArchiver)
XML archival.
|
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, toPatternformat, format, getAvailableLocales, getCurrencyInstance, getCurrencyInstance, getInstance, getInstance, getIntegerInstance, getIntegerInstance, getNumberInstance, getNumberInstance, getPercentInstance, getPercentInstance, isGroupingUsed, isParseIntegerOnly, parse, parseObject, setParseIntegerOnlypublic static RMNumberFormat PLAIN
public static RMNumberFormat BASIC
public static RMNumberFormat DOLLARS
public RMNumberFormat()
public RMNumberFormat(java.lang.String aFormatString)
public RMNumberFormat(RMNumberFormat aFormat)
public java.lang.String getNullString()
public void setNullString(java.lang.String aString)
public boolean isNegativeInRed()
public void setNegativeInRed(boolean aFlag)
public java.lang.String getThousandsSeparator()
public void setThousandsSeparator(java.lang.String aValue)
public java.lang.String getDecimalSeparator()
public void setDecimalSeparator(java.lang.String aValue)
public java.lang.String getFormatString()
getFormatString in interface RMFormatpublic void setFormatString(java.lang.String aFormat)
setFormatString in interface RMFormatpublic java.lang.Object formatRM(java.lang.Object anObj)
public boolean equals(java.lang.Object anObj)
equals in class java.text.DecimalFormatpublic RXElement toXML(RXArchiver anArchiver)
public java.lang.Object fromXML(RXArchiver anArchiver, RXElement anElement)
public java.lang.Object initWithArchiver(RMArchiver anArchiver)
initWithArchiver in interface RMArchiver.Archiving