com.ibm.commerce.marketing.promotion.condition

Class Constraint

  • java.lang.Object
    • com.ibm.commerce.marketing.promotion.condition.Constraint
  • All Implemented Interfaces:
    XMLizable, java.io.Serializable


    public class Constraint
    extends java.lang.Object
    implements XMLizable
    A block of XML that describes pattern elements, which are based on a list of filters. Combining Filter Chain and Weighted Range, we are able to define concepts like: At least X number of order items that satisfy the following conditions. The �At least X� part is expressed using the weighted range and the �following conditions� is expressed using a Filter Chain. The entire logical unit composes the semantics of a constraint.

    XML Snippet of Constraint:

      <Constraint impl= "com.ibm.commerce.marketing.promotion.condition.Constraint">
            <!-- Quantity requirement of this constraint -->
            <WeightedRange impl= "com.ibm.commerce.marketing.promotion.condition.WeightedRange">
                    <!-- Minimum number of items is 1 --> 
                    <LowerBound>1</LowerBound>
      
                    <!-- Maximum number of items is not limited -->
                    <UpperBound>-1</UpperBound>
      
                    <!-- Match as many items that satisfy the criteria defined in 
                    the filter chain next -->
                    <Weight>1</Weight>
            </WeightedRange>
     
            <!-- Selection criteria -->
            <FilterChain impl= "com.ibm.commerce.marketing.promotion.condition.FilterChain">
      
            <!-- Multiple filters can be specified, the are applied in a 
            contiguous fashion, that is, connected using a logical "and". -->
            <!-- The dummy filter returns anything passed to it, it 
            effectively selects anything -->
                    <Filter impl= "com.ibm.commerce.marketing.promotion.condition.DummyFilter" />
            </FilterChain>
     
      <!-- The combination of the quantity requirement and the filter 
      chain would return everything present in the shopcart as one big 
      matched pattern -->
      
      </Constraint>
     
     
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String COPYRIGHT
      IBM copyright notice field.
    • Constructor Summary

      Constructors 
      Constructor and Description
      Constraint()
      Constructor for Constraint.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      int apply(LineItemSet input, java.util.Vector output, PromotionContext context)
      Apply the filters from the FilterChain and the quantity requirements from the WeightedRange of the constraint, to the input LineItemSet and determine if and how many times the constraint has been satisfied.
      void fromXML(org.w3c.dom.Node anXMLNode)
      Transforms the XML node into its corresponding real Object.
      FilterChain[] getFilterChains()
      Returns the filter chains that make up this constraint
      WeightedRange getWeightedRange()
      Returns a weighted range that is part of the definition of this constraint
      void setFilterChains(FilterChain[] chains)
      Sets the filter chains that are part of the definition of this constraint
      void setWeightedRange(WeightedRange range)
      Sets the weighted range that is part of the definition of this constraint
      java.lang.String toXML()
      Converts the object into its corresponding XML format representation.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM copyright notice field.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Constraint

        public Constraint()
        Constructor for Constraint.
    • Method Detail

      • apply

        public int apply(LineItemSet input,
                         java.util.Vector output,
                         PromotionContext context)
        Apply the filters from the FilterChain and the quantity requirements from the WeightedRange of the constraint, to the input LineItemSet and determine if and how many times the constraint has been satisfied.
        Parameters:
        input - LineItemSet
        output - a vector of matched LineItemSets
        context - PromotionContext
        Returns:
        number of times this constraint has been satisfied, possible values are -1: infinite number of times, 0: not satisfied, or any positive numbers. For example, if the lower boundary of the WeightedRange is zero, then this means that the constraint is optional and the number of matches is infinite (indicated by the value of -1).
      • getFilterChains

        public FilterChain[] getFilterChains()
        Returns the filter chains that make up this constraint
        Returns:
        an array of filter chains
      • getWeightedRange

        public WeightedRange getWeightedRange()
        Returns a weighted range that is part of the definition of this constraint
        Returns:
        a WeightedRange
      • setFilterChains

        public void setFilterChains(FilterChain[] chains)
        Sets the filter chains that are part of the definition of this constraint
        Parameters:
        chains - an array of FilterChains
      • setWeightedRange

        public void setWeightedRange(WeightedRange range)
        Sets the weighted range that is part of the definition of this constraint
        Parameters:
        range - the WeightedRange to set.