com.ibm.commerce.price.utils
Class UnitManager

java.lang.Object
  |
  +--com.ibm.commerce.price.utils.UnitManager
All Implemented Interfaces:
Registry
Direct Known Subclasses:
CurrencyManager, QuantityManager

public abstract class UnitManager
extends java.lang.Object
implements Registry

Abstract base class for manager classes.


Field Summary
static int ROUND_METHOD_ROUND
           
static int ROUND_METHOD_TRUNCATION
           
 
Fields inherited from interface com.ibm.commerce.registry.Registry
COPYRIGHT
 
Constructor Summary
protected UnitManager(com.ibm.commerce.price.utils.Converters aConverters, com.ibm.commerce.price.utils.Formatters aFormatters, com.ibm.commerce.price.utils.FormattedUnitAmount aFormattedUnitAmount, com.ibm.commerce.price.utils.FormatDesc aFormatDesc)
          UnitManager constructor.
 
Method Summary
protected  boolean checkStoreGroupConverter()
          Do we check that there is a store group level converter? IBM Internal Use Only.
protected  UnitAmount convert(UnitAmount aUnitAmount, StoreAccessBean aStoreAccessBean, java.lang.String toUnit)
          Convert a unit amount to a new unit.
protected abstract  java.lang.String getClassName()
          Get the class name.
protected  com.ibm.commerce.price.utils.Converter getConverter(StoreAccessBean aStoreAccessBean, java.lang.String aFromUnit, java.lang.String aToUnit)
          Get the appropriate converter in the specified store.
protected  com.ibm.commerce.price.utils.Converters getConverters()
          Get the converters container.
protected  java.math.BigDecimal getCustomizedRoundingMultipleBD(StoreAccessBean aStoreAccessBean, java.lang.String aUnit, java.lang.Integer aNumbrUsgId)
          Get the customized rounding multiple as a BigDecimal.
protected  java.math.BigDecimal getCustomizedRoundingMultipleBD(StoreAccessBean aStoreAccessBean, java.lang.String aUnit, java.lang.String aNumberUsage)
          Get the customized rounding multiple as a BigDecimal.
protected  java.lang.Double getCustomizedRoundingMultipleD(StoreAccessBean aStoreAccessBean, java.lang.String aUnit, java.lang.Integer aNumbrUsgId)
          Get the customized rounding multiple as a Double.
protected  java.lang.Double getCustomizedRoundingMultipleD(StoreAccessBean aStoreAccessBean, java.lang.String aUnit, java.lang.String aNumberUsage)
          Get the customized rounding multiple as a Double.
 int getCustomizedRoundMethod(StoreAccessBean aStoreAccessBean, java.lang.String aUnit)
          Get the rounding method used for a particular unit.
 int getCustomizedRoundMethod(StoreAccessBean aStoreAccessBean, java.lang.String aUnit, java.lang.String aNumberUsage)
          Get the rounding method used for a particular unit.
protected  java.lang.String getCustomizedString(StoreAccessBean aStoreAccessBean, java.lang.String aUnit, java.lang.Integer aLanguageId, java.lang.Integer aNumbrUsgId)
          Get the customized string from the format table.
 java.lang.String getCustomizedString(StoreAccessBean aStoreAccessBean, java.lang.String aUnit, java.lang.Integer aLanguageId, java.lang.String aNumberUsage)
          Get the customized string from the format table.
protected  java.lang.String getDescription(StoreAccessBean aStoreAccessBean, java.lang.String aUnit, java.lang.Integer aLanguageId, java.lang.Integer aNumbrUsgId)
          Get the description of the specified units.
 java.lang.String getDescription(StoreAccessBean aStoreAccessBean, java.lang.String aUnit, java.lang.Integer aLanguageId, java.lang.String aNumberUsage)
          Get the description of the specified units.
protected  com.ibm.commerce.price.utils.FormattedUnitAmount getFormattedUnitAmount(UnitAmount aUnitAmount, StoreAccessBean aStoreAccessBean, java.lang.Integer aLanguageId, java.lang.Integer aNumbrUsgId)
          Get a formatted unit amount for display purposes based on the formatting rules defined in the database.
protected  com.ibm.commerce.price.utils.FormattedUnitAmount getFormattedUnitAmount(UnitAmount aUnitAmount, StoreAccessBean aStoreAccessBean, java.lang.Integer aLanguageId, java.lang.String aNumberUsage)
          Get a formatted unit amount for display purposes based on the formatting rules defined in the database.
protected  com.ibm.commerce.price.utils.Formatter getFormatter(StoreAccessBean aStoreAccessBean, java.lang.String aUnit, java.lang.Integer aNumbrUsgId)
          Get the formatter with the specified number usage identifer for the store.
protected  com.ibm.commerce.price.utils.Converter getParticularConverter(java.lang.Integer aStoreEntityId, java.lang.String fromUnit, java.lang.String toUnit)
          IBM Internal Use Only.
protected  java.math.BigDecimal getRoundingMultipleBD(StoreAccessBean aStoreAccessBean, java.lang.String aUnit, java.lang.Integer aNumbrUsgId)
          Get the rounding multiple as a BigDecimal.
protected  java.math.BigDecimal getRoundingMultipleBD(StoreAccessBean aStoreAccessBean, java.lang.String aUnit, java.lang.String aNumberUsage)
          Get the rounding multiple as a BigDecimal.
protected  java.lang.Double getRoundingMultipleD(StoreAccessBean aStoreAccessBean, java.lang.String aUnit, java.lang.Integer aNumbrUsgId)
          Get the rounding multiple as a Double.
protected  java.lang.Double getRoundingMultipleD(StoreAccessBean aStoreAccessBean, java.lang.String aUnit, java.lang.String aNumberUsage)
          Get the rounding multiple as a Double.
protected abstract  java.lang.Integer getStoreIdForConverter(StoreAccessBean aStoreAccessBean)
          Get the storeId to use to search for a converter.
protected  java.lang.String getSymbol(StoreAccessBean aStoreAccessBean, java.lang.String aUnit, java.lang.Integer aLanguageId, java.lang.Integer aNumbrUsgId)
          Get the symbol information from the format table.
 java.lang.String getSymbol(StoreAccessBean aStoreAccessBean, java.lang.String aUnit, java.lang.Integer aLanguageId, java.lang.String aNumberUsage)
          Get the symbol information from the format table.
 void refresh()
          Refresh the manager cache.
protected  void refreshCache(com.ibm.commerce.price.utils.Converters aConverters, com.ibm.commerce.price.utils.Formatters aFormatters, int theCacheToRefresh)
          Refresh the cache.
protected  void refreshExtension(com.ibm.commerce.price.utils.Formatters theTempFormatters)
          Extension to the refresh.
protected  void refreshOthers(com.ibm.commerce.price.utils.Converters aConverters)
          Refresh other containers.
protected  java.lang.Integer resolveNumberUsageId(java.lang.String aNumberUsage)
          Resolve the number usage code to an Id.
protected  void round(UnitAmount aUnitAmount, StoreAccessBean aStoreAccessBean, java.lang.Integer aNumbrUsgId)
          Round the unit amount to the appropriate number of decimal places.
protected  void round(UnitAmount aUnitAmount, StoreAccessBean aStoreAccessBean, java.lang.String aNumberUsage)
          Round the unit amount to the appropriate number of decimal places.
protected  void roundCustomized(UnitAmount aUnitAmount, StoreAccessBean aStoreAccessBean, java.lang.Integer aNumbrUsgId)
          Perform customized rounding to the correct number of decimal places.
protected  void roundCustomized(UnitAmount aUnitAmount, StoreAccessBean aStoreAccessBean, java.lang.String aNumberUsage)
          Perform customized rounding to the correct number of decimal places.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.commerce.registry.Registry
initialize
 

Field Detail

ROUND_METHOD_ROUND

public static final int ROUND_METHOD_ROUND

ROUND_METHOD_TRUNCATION

public static final int ROUND_METHOD_TRUNCATION
Constructor Detail

UnitManager

protected UnitManager(com.ibm.commerce.price.utils.Converters aConverters,
                      com.ibm.commerce.price.utils.Formatters aFormatters,
                      com.ibm.commerce.price.utils.FormattedUnitAmount aFormattedUnitAmount,
                      com.ibm.commerce.price.utils.FormatDesc aFormatDesc)
               throws ECSystemException
UnitManager constructor.
Method Detail

checkStoreGroupConverter

protected boolean checkStoreGroupConverter()
Do we check that there is a store group level converter? IBM Internal Use Only.
Returns:
true if we should check for store group level converters; false otherwise.

convert

protected UnitAmount convert(UnitAmount aUnitAmount,
                             StoreAccessBean aStoreAccessBean,
                             java.lang.String toUnit)
                      throws ECSystemException
Convert a unit amount to a new unit.
Parameters:
aUnitAmount - a unit amount to be converted.
aStoreAccessBean - the store access bean to use to choose the appropriate conversion rules.
toUnit - the unit to convert to.
Returns:
the new unit amount in the target unit.

getClassName

protected abstract java.lang.String getClassName()
Get the class name.
Returns:
The name of the class.

getConverter

protected com.ibm.commerce.price.utils.Converter getConverter(StoreAccessBean aStoreAccessBean,
                                                              java.lang.String aFromUnit,
                                                              java.lang.String aToUnit)
                                                       throws ECSystemException
Get the appropriate converter in the specified store.
Parameters:
aStoreAccessBean - The store access bean who owns the conversion.
aFromUnit - The from unit of the conversion.
aToUnit - The to unit of the conversion.
Returns:
The converter.

getConverters

protected com.ibm.commerce.price.utils.Converters getConverters()
Get the converters container.
Returns:
The converters.

getCustomizedRoundingMultipleBD

protected java.math.BigDecimal getCustomizedRoundingMultipleBD(StoreAccessBean aStoreAccessBean,
                                                               java.lang.String aUnit,
                                                               java.lang.Integer aNumbrUsgId)
                                                        throws ECSystemException
Get the customized rounding multiple as a BigDecimal.
Parameters:
aStoreAccessBean - The store for which the rounding multiple applies.
aUnit - The unit for which the rounding multiple applies.
aNumbrUsgId - The number usage identifier to use.
Returns:
The customized rounding multiple.

getCustomizedRoundingMultipleBD

protected java.math.BigDecimal getCustomizedRoundingMultipleBD(StoreAccessBean aStoreAccessBean,
                                                               java.lang.String aUnit,
                                                               java.lang.String aNumberUsage)
                                                        throws ECSystemException
Get the customized rounding multiple as a BigDecimal.
Parameters:
aStoreAccessBean - The store for which the rounding multiple applies.
aUnit - The unit for which the rounding multiple applies.
aNumberUsage - The number usage code to use.
Returns:
The customized rounding multiple.

getCustomizedRoundingMultipleD

protected java.lang.Double getCustomizedRoundingMultipleD(StoreAccessBean aStoreAccessBean,
                                                          java.lang.String aUnit,
                                                          java.lang.Integer aNumbrUsgId)
                                                   throws ECSystemException
Get the customized rounding multiple as a Double.
Parameters:
aStoreAccessBean - The store for which the rounding multiple applies.
aUnit - The unit for which the rounding multiple applies.
aNumbrUsgId - The number usage identifier to use.
Returns:
The customized rounding multiple.

getCustomizedRoundingMultipleD

protected java.lang.Double getCustomizedRoundingMultipleD(StoreAccessBean aStoreAccessBean,
                                                          java.lang.String aUnit,
                                                          java.lang.String aNumberUsage)
                                                   throws ECSystemException
Get the customized rounding multiple as a Double.
Parameters:
aStoreAccessBean - The store for which the rounding multiple applies.
aUnit - The unit for which the rounding multiple applies.
aNumberUsage - The number usage code to use.
Returns:
The customized rounding multiple.

getCustomizedRoundMethod

public int getCustomizedRoundMethod(StoreAccessBean aStoreAccessBean,
                                    java.lang.String aUnit)
                             throws ECSystemException
Get the rounding method used for a particular unit.
Parameters:
aStoreAccessBean - the store for which the rounding method applies.
aUnit - the unit for which the rounding method applies.
Returns:
the rounding method.

getCustomizedRoundMethod

public int getCustomizedRoundMethod(StoreAccessBean aStoreAccessBean,
                                    java.lang.String aUnit,
                                    java.lang.String aNumberUsage)
                             throws ECSystemException
Get the rounding method used for a particular unit.
Parameters:
aStoreAccessBean - the store for which the rounding method applies.
aUnit - the unit for which the rounding method applies.
aNumberUsage - the number usage code.
Returns:
the rounding method.

getCustomizedString

protected java.lang.String getCustomizedString(StoreAccessBean aStoreAccessBean,
                                               java.lang.String aUnit,
                                               java.lang.Integer aLanguageId,
                                               java.lang.Integer aNumbrUsgId)
                                        throws ECSystemException
Get the customized string from the format table.
Parameters:
aStoreAccessBean - the store for choosing the appropriate rule.
aUnit - the unit 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.

getCustomizedString

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

getDescription

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

getDescription

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

getFormattedUnitAmount

protected com.ibm.commerce.price.utils.FormattedUnitAmount getFormattedUnitAmount(UnitAmount aUnitAmount,
                                                                                  StoreAccessBean aStoreAccessBean,
                                                                                  java.lang.Integer aLanguageId,
                                                                                  java.lang.Integer aNumbrUsgId)
                                                                           throws ECSystemException
Get a formatted unit 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:
aUnitAmount - the unit amount to format.
aStoreAccessBean - a store access bean.
aLanguageId - a language ID.
aNumbrUsgId - The number usage identifier to use.
Returns:
the formatted unit amount.

getFormattedUnitAmount

protected com.ibm.commerce.price.utils.FormattedUnitAmount getFormattedUnitAmount(UnitAmount aUnitAmount,
                                                                                  StoreAccessBean aStoreAccessBean,
                                                                                  java.lang.Integer aLanguageId,
                                                                                  java.lang.String aNumberUsage)
                                                                           throws ECSystemException
Get a formatted unit 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:
aUnitAmount - the unit amount to format.
aStoreAccessBean - a store access bean.
aLanguageId - a language ID.
aNumberUsage - The number usage code to use.
Returns:
the formatted unit amount.

getFormatter

protected com.ibm.commerce.price.utils.Formatter getFormatter(StoreAccessBean aStoreAccessBean,
                                                              java.lang.String aUnit,
                                                              java.lang.Integer aNumbrUsgId)
                                                       throws ECSystemException
Get the formatter with the specified number usage identifer for the store. If one doesn't exist, get one from the store group. If one still cannot be found, try the default number usage for the store and if necessary the store group. If a formatter still cannot be found, use the default formatter.
Parameters:
aStoreAccessBean - The store access bean.
aUnit - The unit for the formatter.
aNumbrUsgId - The number usage identifier to use.
Returns:
The formatter.

getParticularConverter

protected com.ibm.commerce.price.utils.Converter getParticularConverter(java.lang.Integer aStoreEntityId,
                                                                        java.lang.String fromUnit,
                                                                        java.lang.String toUnit)
IBM Internal Use Only.

getRoundingMultipleBD

protected java.math.BigDecimal getRoundingMultipleBD(StoreAccessBean aStoreAccessBean,
                                                     java.lang.String aUnit,
                                                     java.lang.Integer aNumbrUsgId)
                                              throws ECSystemException
Get the rounding multiple as a BigDecimal.
Parameters:
aStoreAccessBean - The store for which the rounding multiple applies.
aUnit - The unit for which the rounding multiple applies.
aNumbrUsgId - The number usage identifier to use.
Returns:
The rounding multiple.

getRoundingMultipleBD

protected java.math.BigDecimal getRoundingMultipleBD(StoreAccessBean aStoreAccessBean,
                                                     java.lang.String aUnit,
                                                     java.lang.String aNumberUsage)
                                              throws ECSystemException
Get the rounding multiple as a BigDecimal.
Parameters:
aStoreAccessBean - The store for which the rounding multiple applies.
aUnit - The unit for which the rounding multiple applies.
aNumberUsage - The number usage code to use.
Returns:
The rounding multiple.

getRoundingMultipleD

protected java.lang.Double getRoundingMultipleD(StoreAccessBean aStoreAccessBean,
                                                java.lang.String aUnit,
                                                java.lang.Integer aNumbrUsgId)
                                         throws ECSystemException
Get the rounding multiple as a Double.
Parameters:
aStoreAccessBean - The store for which the rounding multiple applies.
aUnit - The unit for which the rounding multiple applies.
aNumbrUsgId - The number usage identifier to use.
Returns:
The rounding multiple.

getRoundingMultipleD

protected java.lang.Double getRoundingMultipleD(StoreAccessBean aStoreAccessBean,
                                                java.lang.String aUnit,
                                                java.lang.String aNumberUsage)
                                         throws ECSystemException
Get the rounding multiple as a Double.
Parameters:
aStoreAccessBean - The store for which the rounding multiple applies.
aUnit - The unit for which the rounding multiple applies.
aNumberUsage - The number usage code to use.
Returns:
The rounding multiple.

getStoreIdForConverter

protected abstract java.lang.Integer getStoreIdForConverter(StoreAccessBean aStoreAccessBean)
                                                     throws ECSystemException
Get the storeId to use to search for a converter. IBM Internal Use Only.
Parameters:
aStoreAccessBean - com.ibm.commerce.common.objects.StoreAccessBean
Returns:
java.lang.Integer

getSymbol

protected java.lang.String getSymbol(StoreAccessBean aStoreAccessBean,
                                     java.lang.String aUnit,
                                     java.lang.Integer aLanguageId,
                                     java.lang.Integer aNumbrUsgId)
                              throws ECSystemException
Get the symbol information from the format table.
Parameters:
aStoreAccessBean - the store.
aUnit - the unit.
aLanguageId - the language Id of the language for the symbol.
aNumbrUsgId - The number usage identifier to use.
Returns:
the symbol.

getSymbol

public java.lang.String getSymbol(StoreAccessBean aStoreAccessBean,
                                  java.lang.String aUnit,
                                  java.lang.Integer aLanguageId,
                                  java.lang.String aNumberUsage)
                           throws ECSystemException
Get the symbol information from the format table.
Parameters:
aStoreAccessBean - the store.
aUnit - the unit.
aLanguageId - the language Id of the language for the symbol.
aNumberUsage - the number usage code.
Returns:
the symbol.

refresh

public void refresh()
             throws ECSystemException
Refresh the manager cache.
Specified by:
refresh in interface Registry
Following copied from interface: com.ibm.commerce.registry.Registry
Throws:
-  

refreshCache

protected void refreshCache(com.ibm.commerce.price.utils.Converters aConverters,
                            com.ibm.commerce.price.utils.Formatters aFormatters,
                            int theCacheToRefresh)
                     throws ECSystemException
Refresh the cache.

refreshExtension

protected void refreshExtension(com.ibm.commerce.price.utils.Formatters theTempFormatters)
                         throws ECSystemException
Extension to the refresh.
Parameters:
theTempFormatters - com.ibm.commerce.price.utils.Formatters

refreshOthers

protected void refreshOthers(com.ibm.commerce.price.utils.Converters aConverters)
                      throws ECSystemException
Refresh other containers.

resolveNumberUsageId

protected java.lang.Integer resolveNumberUsageId(java.lang.String aNumberUsage)
                                          throws ECSystemException
Resolve the number usage code to an Id.
Parameters:
aNumberUsage - The number usage code.
Returns:
The number usage identifier.

round

protected void round(UnitAmount aUnitAmount,
                     StoreAccessBean aStoreAccessBean,
                     java.lang.Integer aNumbrUsgId)
              throws ECSystemException
Round the unit amount to the appropriate number of decimal places. This ignores the roundingMultiple and roundingMethod columns of the format table.
Parameters:
aUnitAmount - the unit amount to round.
aStoreAccessBean - the store.

round

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

roundCustomized

protected void roundCustomized(UnitAmount aUnitAmount,
                               StoreAccessBean aStoreAccessBean,
                               java.lang.Integer aNumbrUsgId)
                        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:
aUnitAmount - the unit amount to round.
aStoreAccessBean - the store.

roundCustomized

protected void roundCustomized(UnitAmount aUnitAmount,
                               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:
aUnitAmount - the unit amount to round.
aStoreAccessBean - the store.
aNumberUsage - the number usage code.