public class ItemSortingFilter extends java.lang.Object implements Filter
ItemSortingFilter
sorts the input LineItemSet
according to the order item price (before any discounts), using
the specified SortingMethod
and returns the ordered
LineItem
s. By default, the order items are sorted in
ascending order of prices. If the SortingMethod specified is
'PriceHighToLow', then the order items are sorted in descending order of
prices.
By default, an item LineItemSet
is split from the start to
the end for pattern matching. If the SplitMethod specified is 'SplitEndToStart',
then the item is split from the end to the start.
This class implements the Filter
interface. XML Snippet for
this type of Filter
:
<Filter impl="com.ibm.commerce.marketing.promotion.condition.ItemSortingFilter"> <!-- PriceHighToLow or PriceLowToHigh --> <SortingMethod>PriceLowToHigh</SortingMethod> <SplitMethod>SplitStartToEnd</SplitMethod> </Filter>
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COPYRIGHT
IBM copyright notice field.
|
static java.lang.String |
SORTING_METHOD_PRICE_HIGH_TO_LOW
XML value 'PriceHighToLow'.
|
static java.lang.String |
SORTING_METHOD_PRICE_LOW_TO_HIGH
XML value 'PriceLowToHigh'.
|
static java.lang.String |
SPLIT_METHOD_END_TO_START
XML value 'SplitEndToStart'.
|
static java.lang.String |
SPLIT_METHOD_START_TO_END
XML value 'SplitStartToEnd'.
|
static java.lang.String |
TAG_FILTER
XML Tag 'Filter'.
|
static java.lang.String |
TAG_SORTING_METHOD
XML Tag 'SortingMethod'.
|
static java.lang.String |
TAG_SPLIT_METHOD
XML Tag 'SplitMethod'.
|
Constructor and Description |
---|
ItemSortingFilter()
Constructor for ItemSortingFilter.
|
Modifier and Type | Method and Description |
---|---|
LineItemSet |
filter(LineItemSet input,
PromotionContext context)
This filter method calls the
getSortedLineItemSet() method
with the AssociatedOrderItem s obtained from
the input LineItemSet . |
void |
fromXML(org.w3c.dom.Node anXMLNode)
Transforms the XML node into its corresponding real Object.
|
LineItemSet |
getSortedLineItemSet(AssociatedOrderItem[] items)
This method takes as input an array of
AssociatedOrderItem s and sorts them according to their prices. |
java.lang.String |
getSortingMethod()
This method gets the sorting method.
|
java.lang.String |
getSplitMethod()
This method gets the split method.
|
void |
setSortingMethod(java.lang.String newSortingMethod)
This method sets the sorting method.
|
void |
setSplitMethod(java.lang.String newSplitMethod)
This method sets the split method.
|
java.lang.String |
toXML()
Converts the object into its corresponding XML format representation.
|
public static final java.lang.String COPYRIGHT
public static final java.lang.String TAG_FILTER
public static final java.lang.String TAG_SORTING_METHOD
public static final java.lang.String TAG_SPLIT_METHOD
public static final java.lang.String SORTING_METHOD_PRICE_HIGH_TO_LOW
public static final java.lang.String SORTING_METHOD_PRICE_LOW_TO_HIGH
public static final java.lang.String SPLIT_METHOD_START_TO_END
public static final java.lang.String SPLIT_METHOD_END_TO_START
public java.lang.String getSortingMethod()
public void setSortingMethod(java.lang.String newSortingMethod)
newSortingMethod
- Set to one of the two constants of
SORTING_METHOD_PRICE_HIGH_TO_LOW or
SORTING_METHOD_PRICE_LOW_TO_HIGHpublic java.lang.String getSplitMethod()
public void setSplitMethod(java.lang.String newSplitMethod)
newSortingMethod
- Set to one of the two constants of
SPLIT_METHOD_START_TO_END or
SPLIT_METHOD_END_TO_STARTpublic LineItemSet filter(LineItemSet input, PromotionContext context)
getSortedLineItemSet()
method
with the AssociatedOrderItem
s obtained from
the input LineItemSet
. The order items are sorted
according to their prices in ascending order by default. If the
SortingMethod of 'PriceHighToLow' is specified, then the sorting is done
in descending order of prices. The sorted LineItemSet is then returned by
the method. If an exception is encountered, then an empty LineItemSet is
returned by the method.filter
in interface Filter
input
- LineItemSet
context
- PromotionContext
LineItemSet
Filter.filter(LineItemSet,
PromotionContext)
public LineItemSet getSortedLineItemSet(AssociatedOrderItem[] items)
AssociatedOrderItem
s and sorts them according to their prices. The
sorting order by default is the ascending order of prices; if however the
SortingMethod of 'PriceHighToLow' is set, then the sorting is done in
descending order of prices.items
- An array of AssociatedOrderItems.public java.lang.String toXML() throws XMLizationException
XMLizable
toXML
in interface XMLizable
XMLizationException
- when this process failsXMLizable.toXML()
public void fromXML(org.w3c.dom.Node anXMLNode) throws DeXMLizationException
XMLizable
fromXML
in interface XMLizable
anXMLNode
- The node that represents an XMLizable objectDeXMLizationException
- when this process failsXMLizable.fromXML(Node)