atg.commerce.pricing
Class QuantityAggregator

java.lang.Object
  extended by atg.commerce.pricing.Aggregator
      extended by atg.commerce.pricing.PropertyAggregator
          extended by atg.commerce.pricing.QuantityAggregator

public class QuantityAggregator
extends PropertyAggregator

An implementation of the Aggregator class. The QuantityAggregator is a special case as we need to consider backwards compatibility. The formula for calculating the aggregated value differs from that of the PropertyAggregator, hence the reason for needing to create an explicit aggregator for this task.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Constructor Summary
QuantityAggregator()
           
 
Method Summary
protected  AggregatorInfo calculate(java.lang.String pOperation, java.lang.Double pAggValueSoFar, java.lang.Long pQuantityMatched, java.lang.Double pTargetValue, CommerceItem pItem, java.util.Map pAttributes)
          This method will calculate (based on the given operation) an aggregated value using pItem.
 java.lang.Number parseValue(java.lang.String pValue, java.lang.Class<?> pType)
          Parses a string value and returns a Number representation.
 
Methods inherited from class atg.commerce.pricing.Aggregator
getOperations, getOverrideProperty, isValidOperation, setOperations, setOverrideProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

QuantityAggregator

public QuantityAggregator()
Method Detail

calculate

protected AggregatorInfo calculate(java.lang.String pOperation,
                                   java.lang.Double pAggValueSoFar,
                                   java.lang.Long pQuantityMatched,
                                   java.lang.Double pTargetValue,
                                   CommerceItem pItem,
                                   java.util.Map pAttributes)
                            throws PricingException
This method will calculate (based on the given operation) an aggregated value using pItem.

Overrides:
calculate in class PropertyAggregator
Parameters:
pOperation - the operation to invoke on the aggregator
pAggValueSoFar - the aggregated value so far, which may be potentially derived from many calculations from multiple items
pQuantityMatched - the number of items that have contributed to the aggregated value
pTargetValue - a value specified in the condition/offer of a promotion which can be used as a target in relation to the aggregated value. May or may not be relevant to an aggregator
pItem - the item that is currently being evaluated
pAttributes - extra parameters
Returns:
holds amended aggValueSoFar and quantityMatched values
Throws:
PricingException

parseValue

public java.lang.Number parseValue(java.lang.String pValue,
                                   java.lang.Class<?> pType)
                            throws java.lang.NumberFormatException
Parses a string value and returns a Number representation.

Overrides:
parseValue in class PropertyAggregator
Parameters:
pValue - value to be parsed
pType - class type of pValue
Returns:
parsed value
Throws:
java.lang.NumberFormatException - if pValue could not be parsed