Package com.highdeal.currency
Class Currency
java.lang.Object
com.highdeal.currency.Currency
- All Implemented Interfaces:
Serializable
The
Java class represents an ISO defined or user defined currency
(such as free mileage).- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCurrency(boolean ISOCurrency, String alphaCode, int numericCode, String symbol, String fractionSymbol, String name, String fractionName, int ratioOfFraction, int smallestUnitAsFraction) Deprecated.Currency(boolean ISOCurrency, String alphaCode, int numericCode, String symbol, String fractionSymbol, String name, String fractionName, int ratioOfFraction, int smallestUnitAsFraction, boolean EMUCurrency, BigDecimal euroConversionRate) Deprecated.Creates a new currency.Currency(String code, int precision, String ISOCode, String name, int numericCode, int ratioOfFraction, int smallestUnitAsFraction) Creates a new currency; It is an ISO 4217 currency ifcodeis equal toISOCode. -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckCompatibility(Currency anotherCurrency) Returns true if anotherCurrency is compatible with this currency, false otherwise.booleanReturnstrueif anotherCurrency is a the same currency as this, false otherwise.Deprecated.Returns the code of the currency.static CurrencyBookgetBook()Returns the book of currencies that is used to match ISO currency code and currency objects.getCode()Returns the unique code of the currency.Deprecated.conversion rate is unknown returns BigDecimal.ZERODeprecated.Fraction name is unknown returns nullDeprecated.Fraction symbol is unknown returns nullReturns the ISO 4217 code of the currency.getName()Returns the name for this currency in the language of the country where this currency is used (e.g.: US Dollar for USD, Euro for EUR).intReturns the ISO 4217 three-digit code, or a user-defined numeric code for a user-defined currency; It is equal to 0 if it is not an ISO currency.intReturns the number of significative digits for the computations of money amounts in this currency.intReturns the ratio of the fraction to the whole (e.g.: 100 for USD); It is equal to 0 if it is not an ISO currencyintReturns the smallest multiples of sub-unit in use for scriptural payment (e.g.: 1 for USD, 100 for BEF).Deprecated.Symbol is unknown returns nullinthashCode()Returns a hash code for this object.booleanDeprecated.returns falsebooleanReturns true if this is an ISO 4217 defined currency, false if this represents a user defined currency.static voidsetBook(CurrencyBook book) Sets the book of currencies that is used to match ISO currency code and currency objects.toString()Gives a string representation of the currency (its ISO 4217 code if it is an ISO currency).
-
Constructor Details
-
Currency
public Currency(String code, int precision, String ISOCode, String name, int numericCode, int ratioOfFraction, int smallestUnitAsFraction) Creates a new currency; It is an ISO 4217 currency ifcodeis equal toISOCode.- Parameters:
code- The unique code of the currency (mandatory, throws anIllegalArgumentExceptionif the code isnullor empty).precision- The precision of this currency (mandatory, throws anIllegalArgumentExceptionif the precision is lower than 0).ISOCode- The ISO 4217 code for this currency (optional)name- The name of the currency (optional)numericCode- The numeric code for this currencyratioOfFraction- The ratio of the fraction to the wholesmallestUnitAsFraction- The smallest unit used in scriptural payment for this currency
-
Currency
Creates a new currency.- Parameters:
code- The unique code of the currency (mandatory, throws anIllegalArgumentExceptionif the code isnullor empty).precision- The precision of this currency (mandatory, throws anIllegalArgumentExceptionif the precision is lower than 0).ISOCode- The ISO 4217 code for this currency (optional)name- The name of the currency (optional)
-
Currency
@Deprecated public Currency(boolean ISOCurrency, String alphaCode, int numericCode, String symbol, String fractionSymbol, String name, String fractionName, int ratioOfFraction, int smallestUnitAsFraction, boolean EMUCurrency, BigDecimal euroConversionRate) Deprecated.Creates a new currency.- Parameters:
ISOCurrency- true if it is an ISO 4217 defined currencyalphaCode- The alphabetic code of this currencynumericCode- The numeric code for this currencysymbol- The symbol for this currencyfractionSymbol- The symbol for the fraction of this currencyratioOfFraction- The ratio of the fraction to the wholename- The name of the currencyfractionName- The name of the fractionsmallestUnitAsFraction- The smallest unit used in scriptural payment for this currencyEMUCurrency-trueif the currency is an European Monetary UniteuroConversionRate- The rate for conversion into euro (only if the currency is an EMU).
-
Currency
@Deprecated public Currency(boolean ISOCurrency, String alphaCode, int numericCode, String symbol, String fractionSymbol, String name, String fractionName, int ratioOfFraction, int smallestUnitAsFraction) Deprecated.Creates a new currency.- Parameters:
ISOCurrency- true if it is an ISO 4217 defined currencyalphaCode- the alphabetic code of this currencynumericCode- the numeric code for this currencysymbol- the symbol for this currencyfractionSymbol- the symbol for the fraction of this currencyname- the name of the currencyfractionName- The fractionNameratioOfFraction- The ratio of the fraction to the wholesmallestUnitAsFraction- The smallest unit used in scriptural payment for this currency
-
-
Method Details
-
equals
Returnstrueif anotherCurrency is a the same currency as this, false otherwise. -
checkCompatibility
Returns true if anotherCurrency is compatible with this currency, false otherwise.- Parameters:
anotherCurrency- The currency to which this currency must be compared to- Returns:
trueif the ISO code of currencies are equals (or if the currency codes are equals in case of ISO codes arenull), false otherwise.
-
hashCode
public int hashCode()Returns a hash code for this object. -
toString
Gives a string representation of the currency (its ISO 4217 code if it is an ISO currency). -
isISOCurrency
public boolean isISOCurrency()Returns true if this is an ISO 4217 defined currency, false if this represents a user defined currency.- Returns:
- true if this is an ISO-defined currency, false otherwise.
-
getAlphaCode
Deprecated.Returns the code of the currency.Returns the ISO 4217 three-letter code if it is an ISO Currency, or a user-defined alphanumeric code if it is a user-defined currency.- Returns:
- The alphabetic code of this currency
-
getNumericCode
public int getNumericCode()Returns the ISO 4217 three-digit code, or a user-defined numeric code for a user-defined currency; It is equal to 0 if it is not an ISO currency.- Returns:
- The numeric code of this currency.
- See Also:
-
getSymbol
Deprecated.Symbol is unknown returns nullReturns the symbol of this currency (e.g.: $ for USD, ₠ for EUR, ¥ for JPY).- Returns:
- The symbol of this currency
-
getFractionSymbol
Deprecated.Fraction symbol is unknown returns nullReturns the symbol for the fraction of this currency (e.g.: ¢ for USD).- Returns:
- The symbol for the fraction
-
getName
Returns the name for this currency in the language of the country where this currency is used (e.g.: US Dollar for USD, Euro for EUR).- Returns:
- The name for this currency
-
getFractionName
Deprecated.Fraction name is unknown returns nullReturns the name for the fraction of this currency in the language of the country where this currency is used (e.g.: cent for USD and EUR).- Returns:
- The fraction of this currency
-
getRatioOfFraction
public int getRatioOfFraction()Returns the ratio of the fraction to the whole (e.g.: 100 for USD); It is equal to 0 if it is not an ISO currency- Returns:
- The ration of the fraction to the whole
-
getSmallestUnitAsFraction
public int getSmallestUnitAsFraction()Returns the smallest multiples of sub-unit in use for scriptural payment (e.g.: 1 for USD, 100 for BEF).(Note: This is different from the smallest coin in cirulation). It is equal to 0 if it is not an ISO currency.
- Returns:
- The smallest unit
-
isEMUCurrency
Deprecated.returns falseReturns true if this currency is a currency of a country member of the European Monetary Union.- Returns:
trueif this currency is a currency of a country member of the EMU.
-
getEuroConversionRate
Deprecated.conversion rate is unknown returns BigDecimal.ZEROReturns the Euro conversion rate for this currency.- Returns:
- The conversion rate in Euro for this currency
-
getPrecision
public int getPrecision()Returns the number of significative digits for the computations of money amounts in this currency. Can be not equal to ISO significative digits if it is not an ISO currency.- Returns:
- The number of significative digits for this currency
-
getCode
Returns the unique code of the currency.- Returns:
- The code of this currency
-
getISOCode
Returns the ISO 4217 code of the currency.- Returns:
- The ISO 4217 code of this currency
-
getBook
Returns the book of currencies that is used to match ISO currency code and currency objects.- Returns:
- The book of currencies
-
setBook
Sets the book of currencies that is used to match ISO currency code and currency objects.- Parameters:
book- The book of currencies
-