edu.umich.eecs.tac.props
Class RetailCatalog

java.lang.Object
  extended by edu.umich.eecs.tac.props.AbstractTransportable
      extended by edu.umich.eecs.tac.props.AbstractTransportableEntryListBacking<S>
          extended by edu.umich.eecs.tac.props.AbstractKeyedEntryList<Product,RetailCatalog.RetailCatalogEntry>
              extended by edu.umich.eecs.tac.props.RetailCatalog
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<Product>, se.sics.isl.transport.Transportable

public class RetailCatalog
extends AbstractKeyedEntryList<Product,RetailCatalog.RetailCatalogEntry>

The class holds the available products, which the users have preferences over. In addition, the advertiser sales profit per conversion is given for each product.

Author:
Patrick Jordan, Lee Callender
See Also:
TAC Documentation, Serialized Form

Nested Class Summary
static class RetailCatalog.RetailCatalogEntry
          The retail catalog entry holds the sales profit for a Product.
 
Constructor Summary
RetailCatalog()
          Creates a empty retail catalog.
 
Method Summary
 int addProduct(Product product)
          Adds the product to the retail catalog.
protected  void afterAddEntry(RetailCatalog.RetailCatalogEntry entry)
          Adds the the manufacturer and component of the supporting entry.
protected  void beforeRemoveEntry(int index)
          Throws an UnsupportedOperationException.
protected  RetailCatalog.RetailCatalogEntry createEntry(Product key)
          Creates a retail catalog entry for a product.
protected  java.lang.Class entryClass()
          Returns the RetailCatalog.RetailCatalogEntry class.
 java.util.Set<java.lang.String> getComponents()
          Returns the set of components for the products.
 java.util.Set<java.lang.String> getManufacturers()
          Returns the set of manufacturers for the products.
 double getSalesProfit(int index)
          Returns the advertiser sales profit for the product at the index.
 double getSalesProfit(Product product)
          Returns the advertiser sales profit for the product.
 void setSalesProfit(int index, double salesProfit)
          Sets the sales profit for the product.
 void setSalesProfit(Product product, double salesProfit)
          Sets the sales profit for the product.
 
Methods inherited from class edu.umich.eecs.tac.props.AbstractKeyedEntryList
addKey, containsKey, getEntry, getKey, indexForEntry, iterator, keys
 
Methods inherited from class edu.umich.eecs.tac.props.AbstractTransportableEntryListBacking
addEntry, afterRemoveEntry, beforeAddEntry, getEntries, getEntry, readAfterEntries, readBeforeEntries, readWithLock, removeEntry, size, toString, toStringAfterEntries, toStringBeforeEntries, writeAfterEntries, writeBeforeEntries, writeWithLock
 
Methods inherited from class edu.umich.eecs.tac.props.AbstractTransportable
getTransportName, isLocked, lock, lockCheck, read, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RetailCatalog

public RetailCatalog()
Creates a empty retail catalog.

Method Detail

getManufacturers

public final java.util.Set<java.lang.String> getManufacturers()
Returns the set of manufacturers for the products.

Returns:
the set of manufacturers for the products.

getComponents

public final java.util.Set<java.lang.String> getComponents()
Returns the set of components for the products.

Returns:
the set of components for the products.

getSalesProfit

public final double getSalesProfit(Product product)
Returns the advertiser sales profit for the product. The sales profit is zero if the product is not in the retail catalog.

Parameters:
product - the product
Returns:
the advertiser sales profit for the product.

getSalesProfit

public final double getSalesProfit(int index)
Returns the advertiser sales profit for the product at the index.

Parameters:
index - the index for the product
Returns:
the advertiser sales profit for the product.

setSalesProfit

public final void setSalesProfit(Product product,
                                 double salesProfit)
                          throws java.lang.IllegalStateException
Sets the sales profit for the product.

Parameters:
product - the product whose sales profit is being set.
salesProfit - the sales profit for the product.
Throws:
java.lang.IllegalStateException - if the retail catalog is locked.

setSalesProfit

public final void setSalesProfit(int index,
                                 double salesProfit)
                          throws java.lang.IllegalStateException
Sets the sales profit for the product.

Parameters:
index - the index for the product
salesProfit - the sales profit for the product.
Throws:
java.lang.IllegalStateException - if the retail catalog is locked.

addProduct

public final int addProduct(Product product)
                     throws java.lang.IllegalStateException
Adds the product to the retail catalog. This method delegates to AbstractKeyedEntryList.addKey(Object) .

Parameters:
product - the product to add.
Returns:
the index of the newly added product.
Throws:
java.lang.IllegalStateException - if the retail catalog is locked.

afterAddEntry

protected final void afterAddEntry(RetailCatalog.RetailCatalogEntry entry)
                            throws java.lang.IllegalStateException
Adds the the manufacturer and component of the supporting entry.

Overrides:
afterAddEntry in class AbstractTransportableEntryListBacking<RetailCatalog.RetailCatalogEntry>
Parameters:
entry - the entry to be added.
Throws:
java.lang.IllegalStateException - if the retail catalog is locked.

createEntry

protected final RetailCatalog.RetailCatalogEntry createEntry(Product key)
Creates a retail catalog entry for a product.

Specified by:
createEntry in class AbstractKeyedEntryList<Product,RetailCatalog.RetailCatalogEntry>
Parameters:
key - the key for the created entry.
Returns:
a retail catalog entry for a product.

beforeRemoveEntry

protected final void beforeRemoveEntry(int index)
                                throws java.lang.UnsupportedOperationException
Throws an UnsupportedOperationException.

Overrides:
beforeRemoveEntry in class AbstractTransportableEntryListBacking<RetailCatalog.RetailCatalogEntry>
Parameters:
index - the index to remove.
Throws:
java.lang.UnsupportedOperationException - throws exception.

entryClass

protected final java.lang.Class entryClass()
Returns the RetailCatalog.RetailCatalogEntry class.

Specified by:
entryClass in class AbstractTransportableEntryListBacking<RetailCatalog.RetailCatalogEntry>
Returns:
the RetailCatalog.RetailCatalogEntry class.


Copyright © 2007-2009 Association for Trading Agent Research. All Rights Reserved.