Class Currency

java.lang.Object
com.highdeal.currency.Currency
All Implemented Interfaces:
Serializable

public class Currency extends Object implements Serializable
The Java class represents an ISO defined or user defined currency (such as free mileage).
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Currency(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. 
    Currency(String code, int precision, String ISOCode, String name)
    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 if code is equal to ISOCode.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    checkCompatibility(Currency anotherCurrency)
    Returns true if anotherCurrency is compatible with this currency, false otherwise.
    boolean
    equals(Object anotherCurrency)
    Returns true if anotherCurrency is a the same currency as this, false otherwise.
    Deprecated.
    Returns the code of the currency.
    Returns the book of currencies that is used to match ISO currency code and currency objects.
    Returns the unique code of the currency.
    Deprecated.
    conversion rate is unknown returns BigDecimal.ZERO
    Deprecated.
    Fraction name is unknown returns null
    Deprecated.
    Fraction symbol is unknown returns null
    Returns the ISO 4217 code of the currency.
    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).
    int
    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.
    int
    Returns the number of significative digits for the computations of money amounts in this currency.
    int
    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
    int
    Returns the smallest multiples of sub-unit in use for scriptural payment (e.g.: 1 for USD, 100 for BEF).
    Deprecated.
    Symbol is unknown returns null
    int
    Returns a hash code for this object.
    boolean
    Deprecated.
    returns false
    boolean
    Returns true if this is an ISO 4217 defined currency, false if this represents a user defined currency.
    static void
    Sets the book of currencies that is used to match ISO currency code and currency objects.
    Gives a string representation of the currency (its ISO 4217 code if it is an ISO currency).

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • 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 if code is equal to ISOCode.
      Parameters:
      code - The unique code of the currency (mandatory, throws an IllegalArgumentException if the code is null or empty).
      precision - The precision of this currency (mandatory, throws an IllegalArgumentException if 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 currency
      ratioOfFraction - The ratio of the fraction to the whole
      smallestUnitAsFraction - The smallest unit used in scriptural payment for this currency
    • Currency

      public Currency(String code, int precision, String ISOCode, String name)
      Creates a new currency.
      Parameters:
      code - The unique code of the currency (mandatory, throws an IllegalArgumentException if the code is null or empty).
      precision - The precision of this currency (mandatory, throws an IllegalArgumentException if 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 currency
      alphaCode - The alphabetic code of this currency
      numericCode - The numeric code for this currency
      symbol - The symbol for this currency
      fractionSymbol - The symbol for the fraction of this currency
      ratioOfFraction - The ratio of the fraction to the whole
      name - The name of the currency
      fractionName - The name of the fraction
      smallestUnitAsFraction - The smallest unit used in scriptural payment for this currency
      EMUCurrency - true if the currency is an European Monetary Unit
      euroConversionRate - 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 currency
      alphaCode - the alphabetic code of this currency
      numericCode - the numeric code for this currency
      symbol - the symbol for this currency
      fractionSymbol - the symbol for the fraction of this currency
      name - the name of the currency
      fractionName - The fractionName
      ratioOfFraction - The ratio of the fraction to the whole
      smallestUnitAsFraction - The smallest unit used in scriptural payment for this currency
  • Method Details

    • equals

      public boolean equals(Object anotherCurrency)
      Returns true if anotherCurrency is a the same currency as this, false otherwise.
      Overrides:
      equals in class Object
      Parameters:
      anotherCurrency - The currency to be compared to this currency
      Returns:
      true if currencies are equals, false otherwise
    • checkCompatibility

      public boolean checkCompatibility(Currency anotherCurrency)
      Returns true if anotherCurrency is compatible with this currency, false otherwise.
      Parameters:
      anotherCurrency - The currency to which this currency must be compared to
      Returns:
      true if the ISO code of currencies are equals (or if the currency codes are equals in case of ISO codes are null), false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code for this object.
      Overrides:
      hashCode in class Object
      Returns:
      A hash code for this object
    • toString

      public String toString()
      Gives a string representation of the currency (its ISO 4217 code if it is an ISO currency).
      Overrides:
      toString in class Object
      Returns:
      A string representation of the 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 public String 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 public String getSymbol()
      Deprecated.
      Symbol is unknown returns null
      Returns the symbol of this currency (e.g.: $ for USD, ₠ for EUR, ¥ for JPY).
      Returns:
      The symbol of this currency
    • getFractionSymbol

      @Deprecated public String getFractionSymbol()
      Deprecated.
      Fraction symbol is unknown returns null
      Returns the symbol for the fraction of this currency (e.g.: ¢ for USD).
      Returns:
      The symbol for the fraction
    • getName

      public String 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 public String getFractionName()
      Deprecated.
      Fraction name is unknown returns null
      Returns 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 public boolean isEMUCurrency()
      Deprecated.
      returns false
      Returns true if this currency is a currency of a country member of the European Monetary Union.
      Returns:
      true if this currency is a currency of a country member of the EMU.
    • getEuroConversionRate

      @Deprecated public BigDecimal getEuroConversionRate()
      Deprecated.
      conversion rate is unknown returns BigDecimal.ZERO
      Returns 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

      public String getCode()
      Returns the unique code of the currency.
      Returns:
      The code of this currency
    • getISOCode

      public String getISOCode()
      Returns the ISO 4217 code of the currency.
      Returns:
      The ISO 4217 code of this currency
    • getBook

      public static CurrencyBook getBook()
      Returns the book of currencies that is used to match ISO currency code and currency objects.
      Returns:
      The book of currencies
    • setBook

      public static void setBook(CurrencyBook book)
      Sets the book of currencies that is used to match ISO currency code and currency objects.
      Parameters:
      book - The book of currencies