IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

com.ibm.btt.bc.fx.impl
Class ForeignExchangeImpl

java.lang.Object
  extended by com.ibm.btt.bc.fx.impl.ForeignExchangeImpl
All Implemented Interfaces:
ForeignExchange

public class ForeignExchangeImpl
extends java.lang.Object
implements ForeignExchange

This class is responsible for performing all foreign exchange calculations.


Constructor Summary
ForeignExchangeImpl()
           
 
Method Summary
 java.math.BigDecimal convert(java.lang.String fromCurrency, java.lang.String toCurrency, java.lang.String fromMonetaryItem, java.lang.String toMonetaryItem, java.math.BigDecimal fromAmount)
          Converts an amount in the source currency to another currency.
 java.math.BigDecimal convertReverse(java.lang.String fromCurrency, java.lang.String toCurrency, java.lang.String fromMonetaryItem, java.lang.String toMonetaryItem, java.math.BigDecimal toAmount)
          Converts the source currency to the specified amount in the destination currency.
 java.lang.String[] getAllSupportedCurrencies()
          Returns all supported currency codes in a Set.
 java.math.BigDecimal getBuyRate(java.lang.String toCurrency, java.lang.String fromMonetaryItem, java.lang.String toMonetaryItem)
          Returns the rate at which the financial institution buys the specified currency against the home currency.
 java.math.BigDecimal getBuyRate(java.lang.String fromCurrency, java.lang.String toCurrency, java.lang.String fromMonetaryItem, java.lang.String toMonetaryItem)
          Returns the rate at which the financial institution buys the specified currency.
 java.lang.String[] getDefinedMonetaryItems()
          Returns all defined monetary item types.
 java.lang.String getHomeCurrency()
          Returns the home currency property of the financial institution.
 long getRatesCacheRefreshInterval()
          Returns the interval to refresh the rates cache.
 RatesProvider getRatesProvider()
          Returns the rates provider instance of the ForeignExchangeEngine.
 java.math.BigDecimal getSellRate(java.lang.String toCurrency, java.lang.String fromMonetaryItem, java.lang.String toMonetaryItem)
          Returns the rate at which the financial institution sells the specified currency against the home currency.
 java.math.BigDecimal getSellRate(java.lang.String fromCurrency, java.lang.String toCurrency, java.lang.String fromMonetaryItem, java.lang.String toMonetaryItem)
          Returns the rate at which the financial institution sells the specified currency.
 void initialize()
           
 void setCurrencyResource(CurrencyResource currencyResource)
          Sets the CurrencyResource instance.
 void setHomeCurrency(java.lang.String homeCurrency)
          Sets the home currency property of the financial institution.
 void setRatesCacheRefreshInterval(java.lang.Long ratesCacheRefreshInterval)
          Sets the interval to refresh the rates cache.
 void setRatesProvider(RatesProvider ratesProvider)
          Sets the rates provider instance of the ForeignExchangeEngine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForeignExchangeImpl

public ForeignExchangeImpl()
Method Detail

initialize

public void initialize()
                throws ForeignExchangeException
Throws:
ForeignExchangeException

getHomeCurrency

public java.lang.String getHomeCurrency()
Returns the home currency property of the financial institution.

Specified by:
getHomeCurrency in interface ForeignExchange
Returns:
the character code of the home currency

setHomeCurrency

public void setHomeCurrency(java.lang.String homeCurrency)
Sets the home currency property of the financial institution.

Parameters:
homeCurrency - the character code of the home currency

getRatesCacheRefreshInterval

public long getRatesCacheRefreshInterval()
Returns the interval to refresh the rates cache.

Returns:
the interval measured in millisecond

setRatesCacheRefreshInterval

public void setRatesCacheRefreshInterval(java.lang.Long ratesCacheRefreshInterval)
Sets the interval to refresh the rates cache.

Parameters:
ratesCacheRefreshInterval - the interval in millisecond

getBuyRate

public java.math.BigDecimal getBuyRate(java.lang.String fromCurrency,
                                       java.lang.String toCurrency,
                                       java.lang.String fromMonetaryItem,
                                       java.lang.String toMonetaryItem)
                                throws ForeignExchangeException
Returns the rate at which the financial institution buys the specified currency.

Specified by:
getBuyRate in interface ForeignExchange
Parameters:
request - the RatesQueryRequest identifying the request data
Returns:
the buy rate
Throws:
ForeignExchangeException - occurs if there is an error accessing the buy rate.

getSellRate

public java.math.BigDecimal getSellRate(java.lang.String fromCurrency,
                                        java.lang.String toCurrency,
                                        java.lang.String fromMonetaryItem,
                                        java.lang.String toMonetaryItem)
                                 throws ForeignExchangeException
Returns the rate at which the financial institution sells the specified currency.

Specified by:
getSellRate in interface ForeignExchange
Parameters:
request - the RatesQueryRequest identifying the request data
Returns:
the sell rate
Throws:
ForeignExchangeException - occurs if there is an error accessing the sell rate.

getAllSupportedCurrencies

public java.lang.String[] getAllSupportedCurrencies()
                                             throws ForeignExchangeException
Description copied from interface: ForeignExchange
Returns all supported currency codes in a Set.

Specified by:
getAllSupportedCurrencies in interface ForeignExchange
Returns:
the Set containing all supported currency codes
Throws:
ForeignExchangeException - occurs if there is an error accessing the Set

getDefinedMonetaryItems

public java.lang.String[] getDefinedMonetaryItems()
                                           throws ForeignExchangeException
Description copied from interface: ForeignExchange
Returns all defined monetary item types.

Specified by:
getDefinedMonetaryItems in interface ForeignExchange
Returns:
the Set containing all supported monetary item types
Throws:
ForeignExchangeException - occurs if there is an error accessing the Set

getRatesProvider

public RatesProvider getRatesProvider()
Returns the rates provider instance of the ForeignExchangeEngine.

Returns:
the rates provider instance of the ForeignExchangeEngine

setRatesProvider

public void setRatesProvider(RatesProvider ratesProvider)
Sets the rates provider instance of the ForeignExchangeEngine.

Parameters:
ratesProvider - the rates provider instance of the ForeignExchangeEngine

convert

public java.math.BigDecimal convert(java.lang.String fromCurrency,
                                    java.lang.String toCurrency,
                                    java.lang.String fromMonetaryItem,
                                    java.lang.String toMonetaryItem,
                                    java.math.BigDecimal fromAmount)
                             throws ForeignExchangeException
Description copied from interface: ForeignExchange
Converts an amount in the source currency to another currency. If you want to specify the destination amount, use the convertReverse method.

Specified by:
convert in interface ForeignExchange
Parameters:
fromCurrency - the String character code of the source currency
toCurrency - the String character code of the destination currency
fromMonetaryItem - the type of monetary item of the source currency
toMonetaryItem - the type of monetary item of the destination currency
fromAmount - the amount of money in the source currency
Returns:
the amount of money in the destination currency
Throws:
ForeignExchangeException - occurs if there is an error converting the currencies

convertReverse

public java.math.BigDecimal convertReverse(java.lang.String fromCurrency,
                                           java.lang.String toCurrency,
                                           java.lang.String fromMonetaryItem,
                                           java.lang.String toMonetaryItem,
                                           java.math.BigDecimal toAmount)
                                    throws ForeignExchangeException
Description copied from interface: ForeignExchange
Converts the source currency to the specified amount in the destination currency. For example, use this method to convert an unknown amount of CAD to GBP 20.00. This method returns the amount of CAD required for the conversion. If you know the amount you want \ converted, use the convert method.

Specified by:
convertReverse in interface ForeignExchange
Parameters:
fromCurrency - the String character code of the source currency
toCurrency - the String character code of the destination currency
fromMonetaryItem - the type of monetary item of the source currency
toMonetaryItem - the type of monetary item of the destination currency
toAmount - the amount of money in the destination currency
Returns:
the amount of money in the source currency
Throws:
ForeignExchangeException - occurs if there is an error converting the currencies

getBuyRate

public java.math.BigDecimal getBuyRate(java.lang.String toCurrency,
                                       java.lang.String fromMonetaryItem,
                                       java.lang.String toMonetaryItem)
                                throws ForeignExchangeException
Description copied from interface: ForeignExchange
Returns the rate at which the financial institution buys the specified currency against the home currency.

Specified by:
getBuyRate in interface ForeignExchange
Parameters:
toCurrency - the String character code of the currency being bought
fromMonetaryItem - the type of monetary item of the source currency
toMonetaryItem - the type of monetary item of the destination currency
Returns:
the buy rate
Throws:
ForeignExchangeException - occurs if there is an error accessing the rates

getSellRate

public java.math.BigDecimal getSellRate(java.lang.String toCurrency,
                                        java.lang.String fromMonetaryItem,
                                        java.lang.String toMonetaryItem)
                                 throws ForeignExchangeException
Description copied from interface: ForeignExchange
Returns the rate at which the financial institution sells the specified currency against the home currency.

Specified by:
getSellRate in interface ForeignExchange
Parameters:
toCurrency - the String character code of the destination currency
fromMonetaryItem - the type of monetary item of the source currency
toMonetaryItem - the type of monetary item of the destination currency
Returns:
the sell rate
Throws:
ForeignExchangeException - occurs if there is an error accessing the rates

setCurrencyResource

public void setCurrencyResource(CurrencyResource currencyResource)
Sets the CurrencyResource instance. If this method is not invoked, the default CurrencyResource implementation is set.

Parameters:
currencyResource - the CurrencyResource instance

IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2011