public class AssociatedOrderItem extends java.lang.Object implements XMLizable, java.lang.Comparable, java.lang.Cloneable
XML Snippet for AssociatedOrderItem:
<AssociatedOrderItem impl="com.ibm.commerce.marketing.promotion.runtime.AssociatedOrderItem" > <OrderItemKey> <OrderItemId>1234</OrderItemId> </OrderItemKey> <StartIndex>2</StartIndex> <Quantity>4</Quantity> </AssociatedOrderItem>
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COPYRIGHT
IBM Copyright
|
static int |
SECTION_FROM_OTHER_ITEM
A section in the three sections as returned by the
markCommonSection(AssociatedOrderItem, AssociatedOrderItem[]) method: is from the operand AssociatedOrderItem |
static int |
SECTION_FROM_THIS_ITEM
A section in the three sections as returned by the
markCommonSection(AssociatedOrderItem, AssociatedOrderItem[]) method: is from this AssociatedOrderItem. |
static int |
SECTION_IS_COMMON
A section in the three sections as returned by the
markCommonSection(AssociatedOrderItem, AssociatedOrderItem[]) method: is common to both this AssociatedOrderItem
and the operand AssociatedOrderItem |
Constructor and Description |
---|
AssociatedOrderItem()
Default constructor for creating an AssociatedOrderItem.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canMerge(AssociatedOrderItem item)
Checks if this
AssociatedOrderItem can be merged with the operand AssociatedOrderItem. |
java.lang.Object |
clone()
Returns null if the CloneNotSupportedException is thrown.
|
int |
compareTo(java.lang.Object obj)
Compares two AssociatedOrderItem objects.
|
AssociatedOrderItem[] |
difference(AssociatedOrderItem item)
Calculates the difference between this associated order item and the parameter item.
|
boolean |
equals(java.lang.Object obj)
Checks to see if two AssociatedOrderItem objects are equal or not.
|
void |
fromXML(org.w3c.dom.Node node)
Builds an AssociatedOrderItem objects based on an XML fragment
|
OrderItem |
getOrderItem()
Returns the order item
|
OrderItemKey |
getOrderItemKey()
Returns the key of the order item with which this AssociatedOrderItem is associated with
|
java.math.BigDecimal |
getQuantity()
Returns the quantity.
|
java.math.BigDecimal |
getStartsAt()
Returns the StartIndex node value of the order item.
|
boolean |
hasCrossSection(AssociatedOrderItem item)
Checks to see if the current AssociatedOrderItem has cross-section with
another AssociatedOrderItem or not.
|
int |
hashCode()
Generates a hash code for the AssociatedOrderItem.
|
int[] |
markCommonSection(AssociatedOrderItem item,
AssociatedOrderItem[] sections)
Seeks out the common sections between this AssociatedOrderItem and the
operand AssociatedOrderItem.
|
AssociatedOrderItem |
merge(AssociatedOrderItem item)
Merges two
AssociatedOrderItem s into one
AssociatedOrderItem . |
boolean |
refersToSameOrderItem(AssociatedOrderItem item)
Tests if two AssociatedOrderItems are referring to the same order item.
|
AssociatedOrderItem[] |
split(java.math.BigDecimal _quantity)
Splits the current AssociatedOrderItem into one or two AssociatedOrderItems based on quantity.
|
AssociatedOrderItem[] |
split(java.math.BigDecimal[] quantities)
Splits the current AssociatedOrderItem into a number of smaller AssociatedOrderItems.
|
AssociatedOrderItem[] |
splitEndToStart(java.math.BigDecimal _quantity)
Splits the current AssociatedOrderItem into one or two AssociatedOrderItems based on quantity, starting from the end of the
current AssociatedOrderItems instead of the start.
|
AssociatedOrderItem[] |
splitEndToStart(java.math.BigDecimal[] quantities)
Splits the current AssociatedOrderItem into a number of smaller AssociatedOrderItems, starting from the end of the
current AssociatedOrderItem intead of the start.
|
java.lang.String |
toString()
Returns a string representation of the AssociatedOrderItem.
|
java.lang.String |
toXML()
Generates the XML representation of this AssociatedOrderItem
|
public static final java.lang.String COPYRIGHT
public static final int SECTION_FROM_THIS_ITEM
markCommonSection(AssociatedOrderItem, AssociatedOrderItem[])
method: is from this AssociatedOrderItem.public static final int SECTION_IS_COMMON
markCommonSection(AssociatedOrderItem, AssociatedOrderItem[])
method: is common to both this AssociatedOrderItem
and the operand AssociatedOrderItempublic static final int SECTION_FROM_OTHER_ITEM
markCommonSection(AssociatedOrderItem, AssociatedOrderItem[])
method: is from the operand AssociatedOrderItempublic AssociatedOrderItem()
public boolean canMerge(AssociatedOrderItem item)
AssociatedOrderItem
can be merged with the operand AssociatedOrderItem.
Two AssociatedOrderItem
s can be merged if and only if they refer to the
same order item. And the quantity subsets of the two AssociatedOrderItem
s is
either joining or overlapping.item
- the other AssociatedOrderItem to be merged with the current one.public AssociatedOrderItem merge(AssociatedOrderItem item)
AssociatedOrderItem
s into one
AssociatedOrderItem
. Merging may be used to produce a
single AssociatedOrderItem if possible, for example when adding
AssociatedOrderItems to a LineItemSet(see method
addLineItem(AssociatedOrderItem)
.item
- the other AssociatedOrderItem to be merged with the current
one.public boolean hasCrossSection(AssociatedOrderItem item)
item
- AssociatedOrderItem the other itempublic int[] markCommonSection(AssociatedOrderItem item, AssociatedOrderItem[] sections)
sections
" is modified and set
with the three sections (three AssociatedOrderItems determined by the above
definition of sections). It is possible that the first or the last AssociatedOrderItem's
quantity is zero, which means either this order item or the operand order item starts
(or ends) in the same position.item
- the operand AssociatedOrderItem to be used for creating sections.sections
- an array of three AssociatedOrderItem. CAUTION: it is the output
parameter and the result of three sections will be set in the array.sections
array
starts from. If this order item and the operand order item (first input parameter)
have no cross section, then a null will be returned.public AssociatedOrderItem[] split(java.math.BigDecimal _quantity)
_quantity
- BigDecimal the quantity to splitpublic AssociatedOrderItem[] split(java.math.BigDecimal[] quantities)
quantities
- BigDecimal[] the quantities used to split the current AssociatedOrderItempublic AssociatedOrderItem[] splitEndToStart(java.math.BigDecimal _quantity)
_quantity
- BigDecimal the quantity to splitpublic AssociatedOrderItem[] splitEndToStart(java.math.BigDecimal[] quantities)
quantities
- BigDecimal[] the quantities used to split the current AssociatedOrderItempublic AssociatedOrderItem[] difference(AssociatedOrderItem item)
item
- parameter associated order itempublic void fromXML(org.w3c.dom.Node node) throws DeXMLizationException
fromXML
in interface XMLizable
node
- Node the XML fragmentDeXMLizationException
- when parsing of the XML fragment fails.public java.lang.String toXML() throws XMLizationException
toXML
in interface XMLizable
XMLizationException
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
java.lang.Object.equals(Object obj)
public int hashCode()
hashCode
in class java.lang.Object
java.lang.Object.hashCode()
public OrderItem getOrderItem()
public java.math.BigDecimal getQuantity()
public java.math.BigDecimal getStartsAt()
public int compareTo(java.lang.Object obj)
compareTo
in interface java.lang.Comparable
Comparable.compareTo(Object)
public OrderItemKey getOrderItemKey()
public boolean refersToSameOrderItem(AssociatedOrderItem item)
item
- the other associated order itempublic java.lang.Object clone()
clone
in class java.lang.Object
java.lang.Object.clone()
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()