com.ibm.commerce.price.utils
Class CurrencyManager

java.lang.Object
  |
  +--com.ibm.commerce.price.utils.UnitManager
        |
        +--com.ibm.commerce.price.utils.CurrencyManager
All Implemented Interfaces:
Registry

public class CurrencyManager
extends UnitManager

Currency manager. This singleton object allows you to retrieve many types of currency information for a store. To retrieve an instance of the CurrencyManager, use the getInstance() method.


Fields inherited from class com.ibm.commerce.price.utils.UnitManager
ROUND_METHOD_ROUND, ROUND_METHOD_TRUNCATION
 
Fields inherited from interface com.ibm.commerce.registry.Registry
COPYRIGHT
 
Constructor Summary
protected CurrencyManager()
          CurrencyManager constructor.
 
Method Summary
 MonetaryAmount convert(MonetaryAmount aMonetaryAmount, StoreAccessBean aStoreAccessBean, java.lang.String toCurrency)
          Convert a monetary amount to a new currency.
protected  java.lang.String getClassName()
          Get the class name.
 java.lang.String[] getCounterCurrencies(StoreAccessBean aStoreAccessBean, java.lang.String aCurrency)
          Get the counter currencies that apply, to a particular currency, in the correct order.
 MonetaryAmount[] getCounterValues(StoreAccessBean aStoreAccessBean, MonetaryAmount aMonetaryAmount)
          Get the list of counter values in the appropriate order.
 java.lang.String getCurrency(StoreAccessBean aStoreAccessBean, java.lang.String aPreferredCurrency, java.lang.Integer aLanguageId)
          Calculate the negotiated shopping currency for the specified store based on the user's preferred currency.
 java.math.BigDecimal getCustomizedRoundingMultiple(StoreAccessBean aStoreAccessBean, java.lang.String aUnit)
          Gets the unit to which rounding occurs.
 java.math.BigDecimal getCustomizedRoundingMultiple(StoreAccessBean aStoreAccessBean, java.lang.String aUnit, java.lang.String aNumberUsage)
          Gets the unit to which rounding occurs.
 java.lang.String getCustomizedString(StoreAccessBean aStoreAccessBean, java.lang.String aCurrency, java.lang.Integer aLanguageId)
          Get the customized string from the format table.
 java.lang.String getDefaultCurrency(StoreAccessBean aStoreAccessBean)
          Get the store level default currency for a particular store.
 java.lang.String getDefaultCurrency(StoreAccessBean aStoreAccessBean, java.lang.Integer aLanguageId)
          Get the default currency for a particular store and language Id.
 java.lang.String getDescription(StoreAccessBean aStoreAccessBean, java.lang.String aCurrency, java.lang.Integer aLanguageId)
          Get the description of the specified currency.
 FormattedMonetaryAmount getFormattedMonetaryAmount(MonetaryAmount aMonetaryAmount, StoreAccessBean aStoreAccessBean, java.lang.Integer aLanguageId)
          Get a formatted monetary amount for display purposes based on the formatting rules defined in the database.
 FormattedMonetaryAmount getFormattedMonetaryAmount(MonetaryAmount aMonetaryAmount, StoreAccessBean aStoreAccessBean, java.lang.Integer aLanguageId, java.lang.String aNumberUsage)
          Get a formatted monetary amount for display purposes based on the formatting rules defined in the database.
static CurrencyManager getInstance()
          Get the instance of the currency manager.
 java.math.BigDecimal getMinApproveAmount(StoreAccessBean aStoreAB, java.lang.String aCurrency)
          Get the minimum approved amount.
 java.math.BigDecimal getMinApproveAmount(StoreAccessBean aStoreAB, java.lang.String aCurrency, java.lang.String aNumberUsage)
          Get the minimum approved amount.
 java.math.BigDecimal getRoundingMultiple(StoreAccessBean aStoreAccessBean, java.lang.String aUnit)
          Gets the unit to which rounding occurs.
 java.math.BigDecimal getRoundingMultiple(StoreAccessBean aStoreAccessBean, java.lang.String aUnit, java.lang.String aNumberUsage)
          Gets the unit to which rounding occurs.
protected  java.lang.Integer getStoreIdForConverter(StoreAccessBean aStoreAccessBean)
          Get the store Id to use for converters.
 java.lang.String[] getSupportedCurrencies(StoreAccessBean aStoreAB)
          Get a list of the currencies supported by a store.
 java.lang.String getSymbol(StoreAccessBean aStoreAccessBean, java.lang.String aCurrency, java.lang.Integer aLanguageId)
          Get the currency symbol information from the currency format table.
 void initialize()
          Used by the registry manager to initialize the currency manager.
protected  void refreshExtension(com.ibm.commerce.price.utils.Formatters theTempFormatters)
          Pass all NumberFormat objects to the tools runtime.
protected  void refreshOthers(com.ibm.commerce.price.utils.Converters aConverters)
          Refresh other containers not handles by the parent class.
 void round(MonetaryAmount aMonetaryAmount, StoreAccessBean aStoreAccessBean)
          Round the monetary amount to the appropriate number of decimal places.
 void round(MonetaryAmount aMonetaryAmount, StoreAccessBean aStoreAccessBean, java.lang.String aNumberUsage)
          Round the monetary amount to the appropriate number of decimal places.
 void roundCustomized(MonetaryAmount aMonetaryAmount, StoreAccessBean aStoreAccessBean)
          Perform customized rounding to the correct number of decimal places.
 void roundCustomized(MonetaryAmount aMonetaryAmount, StoreAccessBean aStoreAccessBean, java.lang.String aNumberUsage)
          Perform customized rounding to the correct number of decimal places.
 
Methods inherited from class com.ibm.commerce.price.utils.UnitManager
checkStoreGroupConverter, convert, getConverter, getConverters, getCustomizedRoundingMultipleBD, getCustomizedRoundingMultipleBD, getCustomizedRoundingMultipleD, getCustomizedRoundingMultipleD, getCustomizedRoundMethod, getCustomizedRoundMethod, getCustomizedString, getCustomizedString, getDescription, getDescription, getFormattedUnitAmount, getFormattedUnitAmount, getFormatter, getParticularConverter, getRoundingMultipleBD, getRoundingMultipleBD, getRoundingMultipleD, getRoundingMultipleD, getSymbol, getSymbol, refresh, refreshCache, resolveNumberUsageId, round, round, roundCustomized, roundCustomized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CurrencyManager

protected CurrencyManager()
                   throws ECSystemException
CurrencyManager constructor.
Method Detail

convert

public MonetaryAmount convert(MonetaryAmount aMonetaryAmount,
                              StoreAccessBean aStoreAccessBean,
                              java.lang.String toCurrency)
                       throws ECSystemException
Convert a monetary amount to a new currency.
Parameters:
aMonetaryAmount - a monetary amount to be converted.
aStoreAccessBean - the store to use to choose the appropriate conversion rules.
toCurrency - the currency to convert to.
Returns:
the new monetary amount in the target currency. If there is no conversion then null is returned.

getClassName

protected java.lang.String getClassName()
Description copied from class: UnitManager
Get the class name.
Overrides:
getClassName in class UnitManager
Following copied from class: com.ibm.commerce.price.utils.UnitManager
Returns:
The name of the class.

getCounterCurrencies

public java.lang.String[] getCounterCurrencies(StoreAccessBean aStoreAccessBean,
                                               java.lang.String aCurrency)
                                        throws ECSystemException
Get the counter currencies that apply, to a particular currency, in the correct order.
Parameters:
aStoreAccessBean - a store.
aCurrency - the currency.
Returns:
an array of counter currencies in the correct order.

getCounterValues

public MonetaryAmount[] getCounterValues(StoreAccessBean aStoreAccessBean,
                                         MonetaryAmount aMonetaryAmount)
                                  throws ECSystemException
Get the list of counter values in the appropriate order.
Parameters:
aStoreAccessBean - the store to use to choose the counter values.
aMonetaryAmount - the monetary amount to find the counter values for.
Returns:
an array of monetary amounts representing the counter values in the correct order.

getCurrency

public java.lang.String getCurrency(StoreAccessBean aStoreAccessBean,
                                    java.lang.String aPreferredCurrency,
                                    java.lang.Integer aLanguageId)
                             throws ECSystemException
Calculate the negotiated shopping currency for the specified store based on the user's preferred currency.
Parameters:
aStoreAccessBean - the store for the currency.
aPreferredCurrency - the user's preferred currency.
aLanguageId - the language Id of the command context (to choose the default currency)
Returns:
the negotiated shopping currency.

getCustomizedRoundingMultiple

public java.math.BigDecimal getCustomizedRoundingMultiple(StoreAccessBean aStoreAccessBean,
                                                          java.lang.String aUnit)
                                                   throws ECSystemException
Gets the unit to which rounding occurs. For instance, if the rounding occurs to the nearest 5 cents then the value 0.05 will be returned.
Parameters:
aStoreAccessBean - the store for which the rounding applies.
aUnit - the currency for which the rounding applies.
Returns:
the rounding unit.

getCustomizedRoundingMultiple

public java.math.BigDecimal getCustomizedRoundingMultiple(StoreAccessBean aStoreAccessBean,
                                                          java.lang.String aUnit,
                                                          java.lang.String aNumberUsage)
                                                   throws ECSystemException
Gets the unit to which rounding occurs. For instance, if the rounding occurs to the nearest 5 cents then the value 0.05 will be returned.
Parameters:
aStoreAccessBean - the store for which the rounding applies.
aUnit - the currency for which the rounding applies.
aNumberUsage - the number usage code.
Returns:
the rounding unit.

getCustomizedString

public java.lang.String getCustomizedString(StoreAccessBean aStoreAccessBean,
                                            java.lang.String aCurrency,
                                            java.lang.Integer aLanguageId)
                                     throws ECSystemException
Get the customized string from the format table.
Parameters:
aStoreAccessBean - the store for choosing the appropriate customized string.
aCurrency - the currency for which to choose the customized string.
aLanguageId - the language Id of the language for the customized string.
Returns:
the customized string from the format table.

getDefaultCurrency

public java.lang.String getDefaultCurrency(StoreAccessBean aStoreAccessBean)
                                    throws ECSystemException
Get the store level default currency for a particular store.
Parameters:
aStoreAccessBean - a store access bean.
Returns:
the default currency.

getDefaultCurrency

public java.lang.String getDefaultCurrency(StoreAccessBean aStoreAccessBean,
                                           java.lang.Integer aLanguageId)
                                    throws ECSystemException
Get the default currency for a particular store and language Id. If there is a store entity level default currency, it will take precedence.
Parameters:
aStoreAccessBean - a store access bean.
aLanguageId - a language Id.
Returns:
the default currency.

getDescription

public java.lang.String getDescription(StoreAccessBean aStoreAccessBean,
                                       java.lang.String aCurrency,
                                       java.lang.Integer aLanguageId)
                                throws ECSystemException
Get the description of the specified currency.
Parameters:
aStoreAccessBean - the store that the description applies to.
aCurrency - the currency that the description is for.
aLanguageId - the language Id of the language for the description.
Returns:
the currency description.

getFormattedMonetaryAmount

public FormattedMonetaryAmount getFormattedMonetaryAmount(MonetaryAmount aMonetaryAmount,
                                                          StoreAccessBean aStoreAccessBean,
                                                          java.lang.Integer aLanguageId)
                                                   throws ECSystemException
Get a formatted monetary amount for display purposes based on the formatting rules defined in the database. Numbers are rounded to the number of decimal places specified in the formatting rules.
Parameters:
aMonetaryAmount - the monetary amount to format.
aStoreAccessBean - a store.
aLanguageId - a language ID.
Returns:
the formatted monetary amount.

getFormattedMonetaryAmount

public FormattedMonetaryAmount getFormattedMonetaryAmount(MonetaryAmount aMonetaryAmount,
                                                          StoreAccessBean aStoreAccessBean,
                                                          java.lang.Integer aLanguageId,
                                                          java.lang.String aNumberUsage)
                                                   throws ECSystemException
Get a formatted monetary amount for display purposes based on the formatting rules defined in the database. Numbers are rounded to the number of decimal places specified in the formatting rules.
Parameters:
aMonetaryAmount - the monetary amount to format.
aStoreAccessBean - a store.
aLanguageId - a language ID.
aNumberUsage - the number usage code.
Returns:
the formatted monetary amount.

getInstance

public static CurrencyManager getInstance()
                                   throws ECSystemException
Get the instance of the currency manager.
Returns:
the Currency Manager instance.

getMinApproveAmount

public java.math.BigDecimal getMinApproveAmount(StoreAccessBean aStoreAB,
                                                java.lang.String aCurrency)
                                         throws ECSystemException
Get the minimum approved amount.
Parameters:
aStoreAB - the store access bean.
aCurrency - the currency.
Returns:
the minimum approved amount.

getMinApproveAmount

public java.math.BigDecimal getMinApproveAmount(StoreAccessBean aStoreAB,
                                                java.lang.String aCurrency,
                                                java.lang.String aNumberUsage)
                                         throws ECSystemException
Get the minimum approved amount.
Parameters:
aStoreAB - the store access bean.
aCurrency - the currency.
aNumberUsage - the number usage code.
Returns:
the minimum approved amount.

getRoundingMultiple

public java.math.BigDecimal getRoundingMultiple(StoreAccessBean aStoreAccessBean,
                                                java.lang.String aUnit)
                                         throws ECSystemException
Gets the unit to which rounding occurs. For instance, if the rounding occurs to the nearest penny then the value 0.01 will be returned.
Parameters:
aStoreAccessBean - the store for which the rounding applies.
aUnit - the currency for which the rounding applies.
Returns:
the rounding unit.

getRoundingMultiple

public java.math.BigDecimal getRoundingMultiple(StoreAccessBean aStoreAccessBean,
                                                java.lang.String aUnit,
                                                java.lang.String aNumberUsage)
                                         throws ECSystemException
Gets the unit to which rounding occurs. For instance, if the rounding occurs to the nearest penny then the value 0.01 will be returned.
Parameters:
aStoreAccessBean - the store for which the rounding applies.
aUnit - the currency for which the rounding applies.
aNumberUsage - the number usage code.
Returns:
the rounding unit.

getStoreIdForConverter

protected java.lang.Integer getStoreIdForConverter(StoreAccessBean aStoreAccessBean)
                                            throws ECSystemException
Get the store Id to use for converters. IBM Internal Use Only.
Overrides:
getStoreIdForConverter in class UnitManager
Following copied from class: com.ibm.commerce.price.utils.UnitManager
Parameters:
aStoreAccessBean - com.ibm.commerce.common.objects.StoreAccessBean
Returns:
java.lang.Integer

getSupportedCurrencies

public java.lang.String[] getSupportedCurrencies(StoreAccessBean aStoreAB)
                                          throws ECSystemException
Get a list of the currencies supported by a store.
Parameters:
aStoreAB - the store access bean for which the currencies are to be found.
Returns:
a list of supported currencies.

getSymbol

public java.lang.String getSymbol(StoreAccessBean aStoreAccessBean,
                                  java.lang.String aCurrency,
                                  java.lang.Integer aLanguageId)
                           throws ECSystemException
Get the currency symbol information from the currency format table.
Parameters:
aStoreAccessBean - the store.
aCurrency - the currency.
aLanguageId - the language Id of the language for the symbol.
Returns:
the currency symbol.

initialize

public void initialize()
                throws java.lang.Exception
Used by the registry manager to initialize the currency manager.

refreshExtension

protected void refreshExtension(com.ibm.commerce.price.utils.Formatters theTempFormatters)
                         throws ECSystemException
Pass all NumberFormat objects to the tools runtime.
Overrides:
refreshExtension in class UnitManager
Parameters:
theTempFormatters - com.ibm.commerce.price.utils.Formatters

refreshOthers

protected void refreshOthers(com.ibm.commerce.price.utils.Converters aConverters)
                      throws ECSystemException
Refresh other containers not handles by the parent class.
Overrides:
refreshOthers in class UnitManager

round

public void round(MonetaryAmount aMonetaryAmount,
                  StoreAccessBean aStoreAccessBean)
           throws ECSystemException
Round the monetary amount to the appropriate number of decimal places. This ignores the roundingMultiple and roundingMethod columns of the currency format table.
Parameters:
aMonetaryAmount - the monetary amount to round.
aStoreAccessBean - the store.

round

public void round(MonetaryAmount aMonetaryAmount,
                  StoreAccessBean aStoreAccessBean,
                  java.lang.String aNumberUsage)
           throws ECSystemException
Round the monetary amount to the appropriate number of decimal places. This ignores the roundingMultiple and roundingMethod columns of the currency format table.
Parameters:
aMonetaryAmount - the monetary amount to round.
aStoreAccessBean - the store.
aNumberUsage - the number usage code.

roundCustomized

public void roundCustomized(MonetaryAmount aMonetaryAmount,
                            StoreAccessBean aStoreAccessBean)
                     throws ECSystemException
Perform customized rounding to the correct number of decimal places. This uses the roundingMultiple and roundingMethod columns of the currency format table.
Parameters:
aMonetaryAmount - the monetary amount to round.
aStoreAccessBean - the store.

roundCustomized

public void roundCustomized(MonetaryAmount aMonetaryAmount,
                            StoreAccessBean aStoreAccessBean,
                            java.lang.String aNumberUsage)
                     throws ECSystemException
Perform customized rounding to the correct number of decimal places. This uses the roundingMultiple and roundingMethod columns of the currency format table.
Parameters:
aMonetaryAmount - the monetary amount to round.
aStoreAccessBean - the store.
aNumberUsage - the number usage code.