it.dtt.ca.ppv
Class Product

java.lang.Object
  extended by it.dtt.ca.ppv.Product
Direct Known Subclasses:
GenericProduct, PPVEvent, PPVPackage, Subscription

public abstract class Product
extends java.lang.Object

Abstract class representing content that can be purchased through the CA system. It is the common base class for packages of events, single PPV events, and subscription services. Where methods take an array as an input parameter, implementations should take a copy of the array. Where methods return an array, a copy should be returned and modifications to the array should be ignored by the implementation until or unless the array is passed back to the implementation as a parameter to a method call.


Field Summary
static int GENERIC_PRODUCT
           
static int PPT_EVENT
           
static int PPV_EVENT
           
static int PPV_PACKAGE
           
static int SUBSCRIPTION
           
 
Constructor Summary
protected Product(java.lang.String id, java.lang.String name, CAPrivateData privateData)
          Called by derived classes to create a product.
protected Product(java.lang.String id, java.lang.String name, CAPrivateData data, java.lang.String[] description, java.lang.String[] extendedDescription, java.util.Date pwStartTime, java.util.Date pwEndTime, Money price, Duration preview)
          Called by derived classes to create a product.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Check if two products have the same CAS ID, meaning they are the same exact product
 Product[] getContainedProducts()
          Get other products contained in this product.
 java.lang.String[] getDescription()
          Returns the product description.
 java.lang.String[] getExtendedDescription()
          Returns the product extended description (e.g. conditions of purchase).
 java.lang.String getId()
          Returns a CAS dependent ID for the specific product.
 java.lang.String getName()
          Returns the product name.
 Duration getPreviewTime()
          Get the total preview time for this product.
 Money getPrice()
          Get the price of the product.
 CAPrivateData getPrivateData()
          Returns Private data for the specific product.
 java.util.Date getPurchaseWindowEndTime()
          Get the ending time of the purchase window for this product.
 java.util.Date getPurchaseWindowStartTime()
          Get the starting time of the purchase window for this product.
abstract  int getType()
          Returns the product type
 int hashCode()
          Returns hash code for the given instance.
abstract  boolean isFree()
          Check if the product is freely viewable.
protected  void setDescription(java.lang.String[] description)
          Deprecated. no replacement Set the product description.
protected  void setExtendedDescription(java.lang.String[] extendedDescription)
          Deprecated. no replacement Set the extended description of this Product.
protected  void setPreviewTime(Duration previewTime)
          Deprecated. no replacement Set the total preview time for this product.
protected  void setPrivateData(CAPrivateData privateData)
          Deprecated. no replacement Sets the Private Data for this event.
protected  void setPurchaseWindowEndTime(java.util.Date purchaseWindowEndTime)
          Deprecated. no replacement Set the ending time of the purchase window for this product.
protected  void setPurchaseWindowStartTime(java.util.Date purchaseWindowStartTime)
          Deprecated. no replacement Set the starting time of the purchase window for this product.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GENERIC_PRODUCT

public static final int GENERIC_PRODUCT
See Also:
Constant Field Values

PPV_EVENT

public static final int PPV_EVENT
See Also:
Constant Field Values

PPT_EVENT

public static final int PPT_EVENT
See Also:
Constant Field Values

SUBSCRIPTION

public static final int SUBSCRIPTION
See Also:
Constant Field Values

PPV_PACKAGE

public static final int PPV_PACKAGE
See Also:
Constant Field Values
Constructor Detail

Product

protected Product(java.lang.String id,
                  java.lang.String name,
                  CAPrivateData data,
                  java.lang.String[] description,
                  java.lang.String[] extendedDescription,
                  java.util.Date pwStartTime,
                  java.util.Date pwEndTime,
                  Money price,
                  Duration preview)
Called by derived classes to create a product.

Parameters:
id - the product id.
name - the product name.
data - the private data associated with this product.
description - the description for this product.
extendedDescription - the extended description for this product.
pwStartTime - the time the purchase window starts.
pwEndTime - the time the purchase window ends.
price - the price to purchase this product.
preview - the preview time for this product.

Product

protected Product(java.lang.String id,
                  java.lang.String name,
                  CAPrivateData privateData)
Called by derived classes to create a product.

Parameters:
id - the product id.
name - the product name.
Method Detail

equals

public boolean equals(java.lang.Object obj)
Check if two products have the same CAS ID, meaning they are the same exact product

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object that is compared with current one
Returns:
true if the CAS ID of the two products is the same

hashCode

public int hashCode()
Returns hash code for the given instance. If equals() method return true for two products, than calling this method on the two products must return the same value.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code associated to the instance.

getId

public java.lang.String getId()
Returns a CAS dependent ID for the specific product.

Returns:
the id of this product.

getPrivateData

public CAPrivateData getPrivateData()
Returns Private data for the specific product.

Returns:
the Private data of this product, or null if none exists.

setPrivateData

protected void setPrivateData(CAPrivateData privateData)
Deprecated. no replacement Sets the Private Data for this event.


getType

public abstract int getType()
Returns the product type

Returns:
product type
See Also:
GENERIC_PRODUCT, PPV_EVENT, SUBSCRIPTION, PPV_PACKAGE

getName

public java.lang.String getName()
Returns the product name.

Returns:
the name

getDescription

public java.lang.String[] getDescription()
                                  throws FieldNotPresentException
Returns the product description.

Returns:
the description.
Throws:
FieldNotPresentException - if the description is not available.

setDescription

protected void setDescription(java.lang.String[] description)
Deprecated. no replacement Set the product description.

Parameters:
description - The description to set.

getExtendedDescription

public java.lang.String[] getExtendedDescription()
                                          throws FieldNotPresentException
Returns the product extended description (e.g. conditions of purchase).

Returns:
the extended description.
Throws:
FieldNotPresentException - if the field is not stored

setExtendedDescription

protected void setExtendedDescription(java.lang.String[] extendedDescription)
Deprecated. no replacement Set the extended description of this Product.

Parameters:
extendedDescription - The extendedDescription to set.

getPurchaseWindowStartTime

public java.util.Date getPurchaseWindowStartTime()
                                          throws FieldNotPresentException
Get the starting time of the purchase window for this product.

Returns:
the date and time from which purchasing is possible.
Throws:
FieldNotPresentException - if the field is not stored.

setPurchaseWindowStartTime

protected void setPurchaseWindowStartTime(java.util.Date purchaseWindowStartTime)
Deprecated. no replacement Set the starting time of the purchase window for this product.

Parameters:
purchaseWindowStartTime - The purchaseWindowStartTime to set.

getPurchaseWindowEndTime

public java.util.Date getPurchaseWindowEndTime()
                                        throws FieldNotPresentException
Get the ending time of the purchase window for this product.

Returns:
the date and time from which purchasing is not possible anymore.
Throws:
FieldNotPresentException - if the field is not stored

setPurchaseWindowEndTime

protected void setPurchaseWindowEndTime(java.util.Date purchaseWindowEndTime)
Deprecated. no replacement Set the ending time of the purchase window for this product.

Parameters:
purchaseWindowEndTime - The purchaseWindowEndTime to set.

getContainedProducts

public Product[] getContainedProducts()
Get other products contained in this product. This method can be used to offer addtional products related to the current product to the end user.

i.e. We may offer the end-user the chance to buy the directors commentary for a movie.

Or in the case of a PPV Package it will contain all the products in the PPV Package.

Returns:
Returns the contained products.

getPrice

public Money getPrice()
               throws FieldNotPresentException
Get the price of the product. In case of a package, this may be different from the sum of the price of the individual events.

Returns:
the price of the product.
Throws:
FieldNotPresentException - if the field is not stored

isFree

public abstract boolean isFree()
                        throws FieldNotPresentException
Check if the product is freely viewable.

Returns:
true if the product is free, false if the product is a pay per view product.
Throws:
FieldNotPresentException - if the field is not stored

getPreviewTime

public Duration getPreviewTime()
                        throws FieldNotPresentException
Get the total preview time for this product. If the Product is a PPVPackage instance, this time represents the total free preview time which can be spent on any product contained in the package. This method will return a Duration of zero if the product has no free preview time, or if the product is free.

Returns:
the free preview time as a Duration instance.
Throws:
FieldNotPresentException - if the preview time is not available.

setPreviewTime

protected void setPreviewTime(Duration previewTime)
Deprecated. no replacement Set the total preview time for this product.

Parameters:
previewTime - The previewTime to set.