DefaultCurrencyData class
A default {@link CurrencyData} implementation, so new methods can be added to the interface without breaking implementors if a reasonable default is available.
class DefaultCurrencyData implements CurrencyData {
final String currencyCode;
final String currencySymbol;
final int fractionDigits;
/**
* Create a default default {@link CurrencyData} instance, returning {@code
* false} for all {@code isFoo} methods and using the standard symbol for the
* portable symbol.
*
* @param currencyCode ISO 4217 currency code
* @param currencySymbol symbol to use for this currency
* @param fractionDigits default number of fraction digits
*/
DefaultCurrencyData(this.currencyCode, this.currencySymbol, [this.fractionDigits = 2]);
String getCurrencyCode() {
return currencyCode;
}
String getCurrencySymbol() {
return currencySymbol;
}
int getDefaultFractionDigits() {
return fractionDigits;
}
String getPortableCurrencySymbol() {
return getCurrencySymbol();
}
String getSimpleCurrencySymbol() {
return getCurrencySymbol();
}
bool isDeprecated() {
return false;
}
bool isSpaceForced() {
return false;
}
bool isSpacingFixed() {
return false;
}
bool isSymbolPositionFixed() {
return false;
}
bool isSymbolPrefix() {
return false;
}
}
Subclasses
Implements
Constructors
new DefaultCurrencyData(String currencyCode, String currencySymbol, [int fractionDigits = 2]) #
Create a default default {@link CurrencyData} instance, returning {@code false} for all {@code isFoo} methods and using the standard symbol for the portable symbol.
@param currencyCode ISO 4217 currency code @param currencySymbol symbol to use for this currency @param fractionDigits default number of fraction digits
DefaultCurrencyData(this.currencyCode, this.currencySymbol, [this.fractionDigits = 2]);
Properties
final String currencyCode #
final String currencyCode
final String currencySymbol #
final String currencySymbol
final int fractionDigits #
final int fractionDigits
Methods
String getCurrencyCode() #
Returns the ISO4217 code for this currency.
String getCurrencyCode() {
return currencyCode;
}
String getCurrencySymbol() #
Returns the default symbol to use for this currency.
String getCurrencySymbol() {
return currencySymbol;
}
int getDefaultFractionDigits() #
Returns the default number of decimal positions for this currency.
int getDefaultFractionDigits() {
return fractionDigits;
}
String getPortableCurrencySymbol() #
Returns the default symbol to use for this currency, intended to be recognizable in most locales. If such a symbol is not available, it is acceptable to return the same value as {@link #getCurrencySymbol()}.
String getPortableCurrencySymbol() {
return getCurrencySymbol();
}
String getSimpleCurrencySymbol() #
Returns the simplest symbol to use for this currency, which is not guaranteed to be unique -- for example, this might return "$" for both USD and CAD. It is acceptable to return the same value as {@link #getCurrencySymbol()}.
String getSimpleCurrencySymbol() {
return getCurrencySymbol();
}
bool isDeprecated() #
Returns true if this currency is deprecated and should not be returned by default in currency lists.
bool isDeprecated() {
return false;
}
bool isSpaceForced() #
Returns true if there should always be a space between the currency symbol and the number, false if there should be no space. Ignored unless {@link #isSpacingFixed()} returns true.
bool isSpaceForced() {
return false;
}
bool isSpacingFixed() #
Returns true if the spacing between the currency symbol and the number is fixed regardless of locale defaults. In this case, spacing will be determined by {@link #isSpaceForced()}.
bool isSpacingFixed() {
return false;
}
bool isSymbolPositionFixed() #
Returns true if the position of the currency symbol relative to the number is fixed regardless of locale defaults. In this case, the position will be determined by {@link #isSymbolPrefix()}.
bool isSymbolPositionFixed() {
return false;
}
bool isSymbolPrefix() #
Returns true if the currency symbol should go before the number, false if it should go after the number. This is ignored unless {@link #isSymbolPositionFixed()} is true.
bool isSymbolPrefix() {
return false;
}