com.highdeal.currency
Class Currency

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

public class Currency
extends java.lang.Object
implements java.io.Serializable

The Java class represents an ISO defined or user defined currency (such as free mileage).

See Also:
Serialized Form

Constructor Summary
Currency(boolean ISOCurrency, java.lang.String alphaCode, int numericCode, java.lang.String symbol, java.lang.String fractionSymbol, java.lang.String name, java.lang.String fractionName, int ratioOfFraction, int smallestUnitAsFraction)
          Deprecated.  
Currency(boolean ISOCurrency, java.lang.String alphaCode, int numericCode, java.lang.String symbol, java.lang.String fractionSymbol, java.lang.String name, java.lang.String fractionName, int ratioOfFraction, int smallestUnitAsFraction, boolean EMUCurrency, java.math.BigDecimal euroConversionRate)
          Deprecated.  
Currency(java.lang.String code, int precision, java.lang.String ISOCode, java.lang.String name)
          Creates a new currency.
Currency(java.lang.String code, int precision, java.lang.String ISOCode, java.lang.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
 boolean checkCompatibility(Currency anotherCurrency)
          Returns true if anotherCurrency is compatible with this currency, false otherwise.
 boolean equals(java.lang.Object anotherCurrency)
          Returns true if anotherCurrency is a the same currency as this, false otherwise.
 java.lang.String getAlphaCode()
          Deprecated. Returns the code of the currency.
static CurrencyBook getBook()
          Returns the book of currencies that is used to match ISO currency code and currency objects.
 java.lang.String getCode()
          Returns the unique code of the currency.
 java.math.BigDecimal getEuroConversionRate()
          Deprecated. conversion rate is unknown returns BigDecimal.ZERO
 java.lang.String getFractionName()
          Deprecated. Fraction name is unknown returns null
 java.lang.String getFractionSymbol()
          Deprecated. Fraction symbol is unknown returns null
 java.lang.String getISOCode()
          Returns the ISO 4217 code of the currency.
 java.lang.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).
 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.
 int getPrecision()
          Returns the number of significative digits for the computations of money amounts in this currency.
 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
 int getSmallestUnitAsFraction()
          Returns the smallest multiples of sub-unit in use for scriptural payment (e.g.: 1 for USD, 100 for BEF).
 java.lang.String getSymbol()
          Deprecated. Symbol is unknown returns null
 int hashCode()
          Returns a hash code for this object.
 boolean isEMUCurrency()
          Deprecated. returns false
 boolean isISOCurrency()
          Returns true if this is an ISO 4217 defined currency, false if this represents a user defined currency.
static void setBook(CurrencyBook book)
          Sets the book of currencies that is used to match ISO currency code and currency objects.
 java.lang.String toString()
          Gives a string representation of the currency (its ISO 4217 code if it is an ISO currency).
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Currency

public Currency(java.lang.String code,
                int precision,
                java.lang.String ISOCode,
                java.lang.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(java.lang.String code,
                int precision,
                java.lang.String ISOCode,
                java.lang.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,
                           java.lang.String alphaCode,
                           int numericCode,
                           java.lang.String symbol,
                           java.lang.String fractionSymbol,
                           java.lang.String name,
                           java.lang.String fractionName,
                           int ratioOfFraction,
                           int smallestUnitAsFraction,
                           boolean EMUCurrency,
                           java.math.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,
                           java.lang.String alphaCode,
                           int numericCode,
                           java.lang.String symbol,
                           java.lang.String fractionSymbol,
                           java.lang.String name,
                           java.lang.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 Detail

equals

public boolean equals(java.lang.Object anotherCurrency)
Returns true if anotherCurrency is a the same currency as this, false otherwise.

Overrides:
equals in class java.lang.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 java.lang.Object
Returns:
A hash code for this object

toString

public java.lang.String toString()
Gives a string representation of the currency (its ISO 4217 code if it is an ISO currency).

Overrides:
toString in class java.lang.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 java.lang.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:
isISOCurrency()

getSymbol

@Deprecated
public java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.math.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 java.lang.String getCode()
Returns the unique code of the currency.

Returns:
The code of this currency

getISOCode

public java.lang.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

Document Published: October 2015 (SAP CC 4.0 SP10 and Later)