com.ibm.commerce.price.utils
Class QuantityManager
java.lang.Object
com.ibm.commerce.price.utils.UnitManager
com.ibm.commerce.price.utils.QuantityManager
- All Implemented Interfaces:
- Registry
- public class QuantityManager
- extends UnitManager
Quantity Manager.
Constructor Summary |
protected |
QuantityManager()
QuantityManager constructor. |
Method Summary |
protected boolean |
checkStoreGroupConverter()
Do we check that there is a store group level converter? IBM Internal Use Only. |
QuantityAmount |
convert(QuantityAmount aQuantityAmount, java.lang.String toQuantityUnit)
Convert a quantity amount to a new quantity unit. |
protected java.lang.String |
getClassName()
Get the class name. |
protected java.lang.String |
getConverionRelationshipType()
Returns null because there is no measurement conversion type. |
protected java.lang.Integer[] |
getConversionStorePath(StoreAccessBean theStoreAB)
Gets the conversion store path. |
java.util.List |
getConvertableUnits(java.lang.String aUnit)
Get all quantity units that can be converted from/to aUnit. |
java.lang.Double |
getCustomizedRoundingMultiple(StoreAccessBean aStoreAccessBean, java.lang.String aUnit)
Gets the unit to which rounding occurs. |
java.lang.Double |
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 aQuantityUnit, java.lang.Integer aLanguageId)
Get the customized string from the format table. |
java.lang.String |
getDescription(StoreAccessBean aStoreAccessBean, java.lang.String aQuantityUnit, java.lang.Integer aLanguageId)
Get the description of the specified quantity unit. |
protected java.lang.String |
getFormatRelationshipType()
Gets the format relationship type. |
FormattedQuantityAmount |
getFormattedQuantityAmount(QuantityAmount aQuantityAmount, StoreAccessBean aStoreAccessBean, java.lang.Integer aLanguageId)
Get a formatted quantity amount for display purposes based on the formatting rules defined in the database. |
FormattedQuantityAmount |
getFormattedQuantityAmount(QuantityAmount aQuantityAmount, StoreAccessBean aStoreAccessBean, java.lang.Integer aLanguageId, java.lang.String aNumberUsage)
Get a formatted quantity amount for display purposes based on the formatting rules defined in the database. |
static QuantityManager |
getInstance()
Get the instance of the quantity manager. |
java.lang.Double |
getRoundingMultiple(StoreAccessBean aStoreAccessBean, java.lang.String aUnit)
Gets the unit to which rounding occurs. |
java.lang.Double |
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 |
getSymbol(StoreAccessBean aStoreAccessBean, java.lang.String aQuantityUnit, java.lang.Integer aLanguageId)
Get the quantity symbol information from the quantity format table. |
void |
initialize()
Used by the registry manager to initialize the quantity manager. |
java.lang.Double |
parsePositiveAmount(java.lang.String anAmount, java.lang.String theUnit, StoreAccessBean aStoreAccessBean, java.lang.Integer aLanguageId, java.lang.String aNumberUsage)
Parses a string (representing a positive number) based on the formatting rules defined in the database. |
void |
round(QuantityAmount aQuantityAmount, StoreAccessBean aStoreAccessBean)
Round the quantity amount to the appropriate number of decimal places. |
void |
round(QuantityAmount aQuantityAmount, StoreAccessBean aStoreAccessBean, java.lang.String aNumberUsage)
Round the quantity amount to the appropriate number of decimal places. |
void |
roundCustomized(QuantityAmount aQuantityAmount, StoreAccessBean aStoreAccessBean)
Perform customized rounding to the correct number of decimal places. |
void |
roundCustomized(QuantityAmount aQuantityAmount, 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 |
convert, getConverter, getConverters, getCustomizedRoundingMultipleBD, getCustomizedRoundingMultipleBD, getCustomizedRoundingMultipleD, getCustomizedRoundingMultipleD, getCustomizedRoundMethod, getCustomizedRoundMethod, getCustomizedString, getCustomizedString, getDescription, getDescription, getFormatDescription, getFormattedUnitAmount, getFormattedUnitAmount, getFormatter, getParticularConverter, getRoundingMultipleBD, getRoundingMultipleBD, getRoundingMultipleD, getRoundingMultipleD, getStoreAB, getStorePath, getSymbol, getSymbol, parsePositiveUnitAmount, parsePositiveUnitAmount, refresh, refreshCache, refreshExtension, refreshOthers, resolveNumberUsageId, round, round, roundCustomized, roundCustomized |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
QuantityManager
protected QuantityManager()
throws ECSystemException
- QuantityManager constructor.
checkStoreGroupConverter
protected boolean checkStoreGroupConverter()
- Description copied from class: UnitManager
- Do we check that there is a store group level converter? IBM Internal Use Only.
-
- Overrides:
- checkStoreGroupConverter in class UnitManager
-
- Returns:
- true if we should check for store group level converters; false otherwise.
getConversionStorePath
protected java.lang.Integer[] getConversionStorePath(StoreAccessBean theStoreAB)
throws ECSystemException
- Gets the conversion store path. This method returns the store ID of the specified store access bean.
-
- Overrides:
- getConversionStorePath in class UnitManager
-
- Parameters:
- theStoreAB - The store access bean to use to get the store path.
- Returns:
- The store path.
- Throws:
- ECSystemException
getConverionRelationshipType
protected java.lang.String getConverionRelationshipType()
- Returns null because there is no measurement conversion type.
-
- Specified by:
- getConverionRelationshipType in class UnitManager
-
- Returns:
- null
getFormatRelationshipType
protected java.lang.String getFormatRelationshipType()
- Gets the format relationship type.
-
- Specified by:
- getFormatRelationshipType in class UnitManager
-
- Returns:
- The format relationship type.
convert
public QuantityAmount convert(QuantityAmount aQuantityAmount,
java.lang.String toQuantityUnit)
throws ECSystemException
- Convert a quantity amount to a new quantity unit. If a conversion cannot be found in the specified store then a conversion will be searched for along the store path for the relationship type com.ibm.commerce.measurement.conversion.
-
- Parameters:
- aQuantityAmount - a quantity amount to be converted.
- toQuantityUnit - the quantity unit to convert to.
- Returns:
- the new quantity amount in the target quantity unit. If there is no conversion then null is returned.
- Throws:
- ECSystemException
getClassName
protected java.lang.String getClassName()
- Description copied from class: UnitManager
- Get the class name.
-
- Specified by:
- getClassName in class UnitManager
-
- Returns:
- The name of the class.
getConvertableUnits
public java.util.List getConvertableUnits(java.lang.String aUnit)
- Get all quantity units that can be converted from/to aUnit.
-
- Parameters:
- aUnit - the starting quantity unit.
- Returns:
- all quantity units that are convertable from/to aUnit (including aUnit).
getCustomizedRoundingMultiple
public java.lang.Double 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 units then the value 0.05 will be returned.
-
- Parameters:
- aStoreAccessBean - the store for which the rounding applies.
- aUnit - the quantity unit for which the rounding applies.
- Returns:
- the rounding unit.
- Throws:
- ECSystemException
getCustomizedRoundingMultiple
public java.lang.Double 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 units then the value 0.05 will be returned.
-
- Parameters:
- aStoreAccessBean - the store for which the rounding applies.
- aUnit - the quantity unit for which the rounding applies.
- aNumberUsage - the number usage code.
- Returns:
- the rounding unit.
- Throws:
- ECSystemException
getCustomizedString
public java.lang.String getCustomizedString(StoreAccessBean aStoreAccessBean,
java.lang.String aQuantityUnit,
java.lang.Integer aLanguageId)
throws ECSystemException
- Get the customized string from the format table.
-
- Parameters:
- aStoreAccessBean - the store for choosing the customized string.
- aQuantityUnit - the quantity 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.
- Throws:
- ECSystemException
getDescription
public java.lang.String getDescription(StoreAccessBean aStoreAccessBean,
java.lang.String aQuantityUnit,
java.lang.Integer aLanguageId)
throws ECSystemException
- Get the description of the specified quantity unit.
-
- Parameters:
- aStoreAccessBean - the store that the description applies to.
- aQuantityUnit - the quantity unit that the description is for.
- aLanguageId - the language Id of the language for the description.
- Returns:
- the quantity unit description.
- Throws:
- ECSystemException
getFormattedQuantityAmount
public FormattedQuantityAmount getFormattedQuantityAmount(QuantityAmount aQuantityAmount,
StoreAccessBean aStoreAccessBean,
java.lang.Integer aLanguageId)
throws ECSystemException
- Get a formatted quantity 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:
- aQuantityAmount - the quantity amount to format.
- aStoreAccessBean - a store.
- aLanguageId - a language ID.
- Returns:
- the formatted quantity amount.
- Throws:
- ECSystemException
getFormattedQuantityAmount
public FormattedQuantityAmount getFormattedQuantityAmount(QuantityAmount aQuantityAmount,
StoreAccessBean aStoreAccessBean,
java.lang.Integer aLanguageId,
java.lang.String aNumberUsage)
throws ECSystemException
- Get a formatted quantity 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:
- aQuantityAmount - the quantity amount to format.
- aStoreAccessBean - a store.
- aLanguageId - a language ID.
- aNumberUsage - the number usage code.
- Returns:
- the formatted quantity amount.
- Throws:
- ECSystemException
getInstance
public static QuantityManager getInstance()
throws ECSystemException
- Get the instance of the quantity manager.
-
- Returns:
- the Quantity Manager instance.
- Throws:
- ECSystemException
getRoundingMultiple
public java.lang.Double getRoundingMultiple(StoreAccessBean aStoreAccessBean,
java.lang.String aUnit)
throws ECSystemException
- Gets the unit to which rounding occurs.
-
- Parameters:
- aStoreAccessBean - the store for which the rounding applies.
- aUnit - the quantity unit for which the rounding applies.
- Returns:
- the rounding unit.
- Throws:
- ECSystemException
getRoundingMultiple
public java.lang.Double getRoundingMultiple(StoreAccessBean aStoreAccessBean,
java.lang.String aUnit,
java.lang.String aNumberUsage)
throws ECSystemException
- Gets the unit to which rounding occurs.
-
- Parameters:
- aStoreAccessBean - the store for which the rounding applies.
- aUnit - the quantity unit for which the rounding applies.
- aNumberUsage - the number usage code.
- Returns:
- the rounding unit.
- Throws:
- ECSystemException
getStoreIdForConverter
protected java.lang.Integer getStoreIdForConverter(StoreAccessBean aStoreAccessBean)
throws ECSystemException
- Get the store Id to use for converters. IBM Internal Use Only.
-
- Specified by:
- getStoreIdForConverter in class UnitManager
-
- Parameters:
- aStoreAccessBean - The store access bean.
- Returns:
- SITE_LEVEL_STORE_ID
- Throws:
- ECSystemException
getSymbol
public java.lang.String getSymbol(StoreAccessBean aStoreAccessBean,
java.lang.String aQuantityUnit,
java.lang.Integer aLanguageId)
throws ECSystemException
- Get the quantity symbol information from the quantity format table.
-
- Parameters:
- aStoreAccessBean - the store.
- aQuantityUnit - the quantity unit.
- aLanguageId - the language Id of the language for the symbol.
- Returns:
- the quantity symbol.
- Throws:
- ECSystemException
initialize
public void initialize()
throws java.lang.Exception
- Used by the registry manager to initialize the quantity manager.
-
- Throws:
- java.lang.Exception
round
public void round(QuantityAmount aQuantityAmount,
StoreAccessBean aStoreAccessBean)
throws ECSystemException
- Round the quantity amount to the appropriate number of decimal places. This ignores the roundingMultiple and roundingMethod columns of the quantity format table.
-
- Parameters:
- aQuantityAmount - the quantity amount to round.
- aStoreAccessBean - the store.
- Throws:
- ECSystemException
round
public void round(QuantityAmount aQuantityAmount,
StoreAccessBean aStoreAccessBean,
java.lang.String aNumberUsage)
throws ECSystemException
- Round the quantity amount to the appropriate number of decimal places. This ignores the roundingMultiple and roundingMethod columns of the quantity format table.
-
- Parameters:
- aQuantityAmount - the quantity amount to round.
- aStoreAccessBean - the store.
- aNumberUsage - the number usage code.
- Throws:
- ECSystemException
roundCustomized
public void roundCustomized(QuantityAmount aQuantityAmount,
StoreAccessBean aStoreAccessBean)
throws ECSystemException
- Perform customized rounding to the correct number of decimal places. This uses the roundingMultiple and roundingMethod columns of the quantity format table.
-
- Parameters:
- aQuantityAmount - the quantity amount to round.
- aStoreAccessBean - the store.
- Throws:
- ECSystemException
roundCustomized
public void roundCustomized(QuantityAmount aQuantityAmount,
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 quantity format table.
-
- Parameters:
- aQuantityAmount - the quantity amount to round.
- aStoreAccessBean - the store.
- aNumberUsage - the number usage code.
- Throws:
- ECSystemException
parsePositiveAmount
public java.lang.Double parsePositiveAmount(java.lang.String anAmount,
java.lang.String theUnit,
StoreAccessBean aStoreAccessBean,
java.lang.Integer aLanguageId,
java.lang.String aNumberUsage)
throws ECSystemException,
java.text.ParseException
- Parses a string (representing a positive number) based on the formatting rules defined in the database.
-
- Parameters:
- anAmount - the amount to parse.
- theUnit - the unit of the value.
- aStoreAccessBean - a store access bean.
- aLanguageId - a language ID.
- aNumberUsage - The number usage code to use.
- Returns:
- the parsed value.
- Throws:
- ECSystemException
- java.text.ParseException
Feedback
(C) Copyright IBM Corporation 1996, 2005. All Rights Reserved.