CurrencyDataImpl class
A POJO for currency data.
class CurrencyDataImpl extends DefaultCurrencyData { /** * Public so CurrencyListGenerator can get to them. As usual with an impl * package, external code should not rely on these values. */ static final int DEPRECATED_FLAG = 128; static final int POS_FIXED_FLAG = 16; static final int POS_SUFFIX_FLAG = 8; static final int PRECISION_MASK = 7; static final int SPACE_FORCED_FLAG = 32; static final int SPACING_FIXED_FLAG = 64; static int testDefaultFractionDigits(int flagsAndPrecision) { return flagsAndPrecision & PRECISION_MASK; } static bool testDeprecated(int flagsAndPrecision) { return (flagsAndPrecision & DEPRECATED_FLAG) != 0; } static bool testSpaceForced(int flagsAndPrecision) { return (flagsAndPrecision & SPACE_FORCED_FLAG) != 0; } static bool testSpacingFixed(int flagsAndPrecision) { return (flagsAndPrecision & SPACING_FIXED_FLAG) != 0; } static bool testSymbolPositionFixed(int flagsAndPrecision) { return (flagsAndPrecision & POS_FIXED_FLAG) != 0; } static bool testSymbolPrefix(int flagsAndPrecision) { return (flagsAndPrecision & POS_SUFFIX_FLAG) != 0; } /** * Flags and # of decimal digits. * * <pre> * d0-d2: # of decimal digits for this currency, 0-7 * d3: currency symbol goes after number, 0=before * d4: currency symbol position is based on d3 * d5: space is forced, 0=no space present * d6: spacing around currency symbol is based on d5 * </pre> */ int flagsAndPrecision; /** * Portable currency symbol, may be the same as {@link #getCurrencySymbol()}. */ String portableCurrencySymbol; /** * Simple currency symbol, may be the same as {@link #getCurrencySymbol()}. */ String simpleCurrencySymbol; /** * Create a new CurrencyData whose portable symbol is the same as its local * symbol. */ CurrencyDataImpl(String currencyCode, String currencySymbol, int flagsAndPrecision, [String portableCurrencySymbol = null, String simpleCurrencySymbol = null]) : super(currencyCode, currencySymbol, testDefaultFractionDigits(flagsAndPrecision)) { this.flagsAndPrecision = flagsAndPrecision; this.portableCurrencySymbol = portableCurrencySymbol == null ? currencySymbol : portableCurrencySymbol; this.simpleCurrencySymbol = simpleCurrencySymbol == null ? currencySymbol : simpleCurrencySymbol; } int getDefaultFractionDigits() { return testDefaultFractionDigits(flagsAndPrecision); } String getPortableCurrencySymbol() { return portableCurrencySymbol; } String getSimpleCurrencySymbol() { return simpleCurrencySymbol; } bool isDeprecated() { return testDeprecated(flagsAndPrecision); } bool isSpaceForced() { return testSpaceForced(flagsAndPrecision); } bool isSpacingFixed() { return testSpacingFixed(flagsAndPrecision); } bool isSymbolPositionFixed() { return testSymbolPositionFixed(flagsAndPrecision); } bool isSymbolPrefix() { return testSymbolPrefix(flagsAndPrecision); } }
Extends
DefaultCurrencyData > CurrencyDataImpl
Static Properties
final int DEPRECATED_FLAG #
Public so CurrencyListGenerator can get to them. As usual with an impl package, external code should not rely on these values.
static final int DEPRECATED_FLAG = 128
final int POS_FIXED_FLAG #
static final int POS_FIXED_FLAG = 16
final int POS_SUFFIX_FLAG #
static final int POS_SUFFIX_FLAG = 8
final int PRECISION_MASK #
static final int PRECISION_MASK = 7
final int SPACE_FORCED_FLAG #
static final int SPACE_FORCED_FLAG = 32
final int SPACING_FIXED_FLAG #
static final int SPACING_FIXED_FLAG = 64
Static Methods
int testDefaultFractionDigits(int flagsAndPrecision) #
static int testDefaultFractionDigits(int flagsAndPrecision) { return flagsAndPrecision & PRECISION_MASK; }
bool testDeprecated(int flagsAndPrecision) #
static bool testDeprecated(int flagsAndPrecision) { return (flagsAndPrecision & DEPRECATED_FLAG) != 0; }
bool testSpaceForced(int flagsAndPrecision) #
static bool testSpaceForced(int flagsAndPrecision) { return (flagsAndPrecision & SPACE_FORCED_FLAG) != 0; }
bool testSpacingFixed(int flagsAndPrecision) #
static bool testSpacingFixed(int flagsAndPrecision) { return (flagsAndPrecision & SPACING_FIXED_FLAG) != 0; }
bool testSymbolPositionFixed(int flagsAndPrecision) #
static bool testSymbolPositionFixed(int flagsAndPrecision) { return (flagsAndPrecision & POS_FIXED_FLAG) != 0; }
bool testSymbolPrefix(int flagsAndPrecision) #
static bool testSymbolPrefix(int flagsAndPrecision) { return (flagsAndPrecision & POS_SUFFIX_FLAG) != 0; }
Constructors
new CurrencyDataImpl(String currencyCode, String currencySymbol, int flagsAndPrecision, [String portableCurrencySymbol = null, String simpleCurrencySymbol = null]) #
Create a new CurrencyData whose portable symbol is the same as its local symbol.
CurrencyDataImpl(String currencyCode, String currencySymbol, int flagsAndPrecision, [String portableCurrencySymbol = null, String simpleCurrencySymbol = null]) : super(currencyCode, currencySymbol, testDefaultFractionDigits(flagsAndPrecision)) { this.flagsAndPrecision = flagsAndPrecision; this.portableCurrencySymbol = portableCurrencySymbol == null ? currencySymbol : portableCurrencySymbol; this.simpleCurrencySymbol = simpleCurrencySymbol == null ? currencySymbol : simpleCurrencySymbol; }
Properties
int flagsAndPrecision #
Flags and # of decimal digits.
d0-d2: # of decimal digits for this currency, 0-7 d3: currency symbol goes after number, 0=before d4: currency symbol position is based on d3 d5: space is forced, 0=no space present d6: spacing around currency symbol is based on d5
int flagsAndPrecision
String portableCurrencySymbol #
Portable currency symbol, may be the same as {@link #getCurrencySymbol()}.
String portableCurrencySymbol
String simpleCurrencySymbol #
Simple currency symbol, may be the same as {@link #getCurrencySymbol()}.
String simpleCurrencySymbol
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 testDefaultFractionDigits(flagsAndPrecision); }
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 portableCurrencySymbol; }
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 simpleCurrencySymbol; }
bool isDeprecated() #
Returns true if this currency is deprecated and should not be returned by default in currency lists.
bool isDeprecated() { return testDeprecated(flagsAndPrecision); }
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 testSpaceForced(flagsAndPrecision); }
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 testSpacingFixed(flagsAndPrecision); }
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 testSymbolPositionFixed(flagsAndPrecision); }
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 testSymbolPrefix(flagsAndPrecision); }