atg.commerce.pricing
Class DoubleRangeShippingCalculator

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.pricing.ShippingCalculatorImpl
              extended by atg.commerce.pricing.DoubleRangeShippingCalculator
All Implemented Interfaces:
ShippingPricingCalculator, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener
Direct Known Subclasses:
PriceRangeShippingCalculator, PropertyRangeShippingCalculator, WeightRangeShippingCalculator

public abstract class DoubleRangeShippingCalculator
extends ShippingCalculatorImpl

An abstract shipping calculator that determines the shipping price based on comparing a value from the ShippingGroup to a series of ranges. The service is configured through the ranges property. With the given array of price range configurations (format: low:high:price) the service parses the values into their double format for use in calculating shipping costs.

For example:

 ranges=00.00:15.99:4.50,\
        16.00:30.99:6.00,\
        31.00:40.99:7.25,\
        41.00:MAX_VALUE:10.00
 
Note: the keyword MAX_VALUE indicates a top end

If the property addAmount is true then instead of setting the price quote amount to the value of the amount property, the calculator adds the amount to the current amount in the price quote. This can be used to configure a "surcharge" calculator, which increases the shipping price.

The shippingMethod property should be set to the name of a particular delivery process. For example: UPS Ground, UPS 2-day or UPS Next Day.

If the ignoreShippingMethod property is true, then this calculator does not expose a shipping method name (through getAvailableMethods). In addition this calculator will always attempt to perform pricing. This option is available if the user is not given a choice of different shipping methods.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
protected  double[] mAmounts
          contains the shipping amounts for each range in ranges
static java.lang.String MAX_VALUE_KEY
          Special value which represents the maximum value in a number set.
protected  double[] mHighRanges
          contains the maximum value of each range in ranges
protected  double[] mLowRanges
          containsthe minimum value of each range in ranges
static char TOKEN
          The separator token which delineates values within the ranges property
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
DoubleRangeShippingCalculator()
          Constructs an instanceof DoubleRangeShippingCalculator
 
Method Summary
 void doStartService()
          Initialize the price ranges for the calculator
protected  double getAmount(Order pOrder, ShippingPriceInfo pPriceQuote, ShippingGroup pShippingGroup, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Returns the amount which should be used as the price for this shipping group
protected  double getRangeComparisonValue(Order pOrder, ShippingGroup pShippingGroup)
          Return the value which should be used as a comparison between the range values
protected abstract  double getRangeComparisonValue(ShippingGroup pShippingGroup)
          Deprecated.  
 java.lang.String[] getRanges()
          Price ranges and shipping costs associated with those ranges.
 void initializeRanges()
          With the given array of price range configurations (format: low:high:price) parse the values into their double format for use in calculating shipping costs
 void setRanges(java.lang.String[] pRanges)
          Price ranges and shipping costs associated with those ranges.
 
Methods inherited from class atg.commerce.pricing.ShippingCalculatorImpl
getAmount, getAvailableMethods, getPricingTools, getShippingMethod, haveItemsToShip, isAddAmount, isIgnoreShippingMethod, performPricing, priceShippingGroup, priceShippingPriceInfo, resetShippingPriceInfo, setAddAmount, setIgnoreShippingMethod, setPricingTools, setShippingMethod
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
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


TOKEN

public static final char TOKEN
The separator token which delineates values within the ranges property

See Also:
Constant Field Values

MAX_VALUE_KEY

public static final java.lang.String MAX_VALUE_KEY
Special value which represents the maximum value in a number set. Used so that ranges don't have to include the numeric represenation of a maximum value. They can use this key instead.

See Also:
Constant Field Values

mLowRanges

protected double[] mLowRanges
containsthe minimum value of each range in ranges


mHighRanges

protected double[] mHighRanges
contains the maximum value of each range in ranges


mAmounts

protected double[] mAmounts
contains the shipping amounts for each range in ranges

Constructor Detail

DoubleRangeShippingCalculator

public DoubleRangeShippingCalculator()
Constructs an instanceof DoubleRangeShippingCalculator

Method Detail

setRanges

public void setRanges(java.lang.String[] pRanges)
Price ranges and shipping costs associated with those ranges.

Parameters:
pRanges - new value to set

getRanges

public java.lang.String[] getRanges()
Price ranges and shipping costs associated with those ranges.

Returns:
property Ranges

doStartService

public void doStartService()
                    throws ServiceException
Initialize the price ranges for the calculator

Overrides:
doStartService in class ShippingCalculatorImpl
Throws:
ServiceException - if there was a problem initializing the price ranges for the calculator

initializeRanges

public void initializeRanges()
                      throws PricingException
With the given array of price range configurations (format: low:high:price) parse the values into their double format for use in calculating shipping costs

Throws:
PricingException - if there was an error while parsing the configuration

getRangeComparisonValue

protected abstract double getRangeComparisonValue(ShippingGroup pShippingGroup)
                                           throws PricingException
Deprecated. 

Return the value which should be used as a comparison between the range values

Parameters:
pShippingGroup - the group that should be inspected for a value which falls between configured range values.
Returns:
the value for which a matching range must be found.
Throws:
PricingException - if there was a problem discovering the range comparison value

getRangeComparisonValue

protected double getRangeComparisonValue(Order pOrder,
                                         ShippingGroup pShippingGroup)
                                  throws PricingException
Return the value which should be used as a comparison between the range values

Parameters:
pShippingGroup - the group that should be inspected for a value which falls between configured range values.
Returns:
the value for which a matching range must be found.
Throws:
PricingException - if there was a problem discovering the range comparison value

getAmount

protected double getAmount(Order pOrder,
                           ShippingPriceInfo pPriceQuote,
                           ShippingGroup pShippingGroup,
                           RepositoryItem pPricingModel,
                           java.util.Locale pLocale,
                           RepositoryItem pProfile,
                           java.util.Map pExtraParameters)
                    throws PricingException
Returns the amount which should be used as the price for this shipping group

Overrides:
getAmount in class ShippingCalculatorImpl
Parameters:
pPriceQuote - the price of the input shipping group
pShippingGroup - the shipping group for which an amount is needed
pPricingModel - a discount which could affect the shipping group's price
pLocale - the locale in which the price is calculated
pProfile - the profile of the person for whom the amount in being generated.
pExtraParameters - any extra parameters that might affect the amount calculation
Returns:
the amount for pricing the input pShippingGroup
Throws:
PricingException - if there is a problem getting the amount (price) for the input shipping group