edu.umich.eecs.tac.props
Class Ad

java.lang.Object
  extended by edu.umich.eecs.tac.props.AbstractTransportable
      extended by edu.umich.eecs.tac.props.Ad
All Implemented Interfaces:
java.io.Serializable, se.sics.isl.transport.Transportable

public class Ad
extends AbstractTransportable

This class represents an advertisement in the TAC/AA scenario. Advertisements can be generic or targeted depending on whether the ad specifies a product. Advertisers will primarily use this class with BidBundle in specifying which advertisements to display for individual queries.

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

Constructor Summary
Ad()
          Creates a generic ad.
Ad(Product product)
          Creates a targeted ad if product is not null.
 
Method Summary
 boolean equals(java.lang.Object o)
          Returns true if the object is an Ad and has the same product or lack thereof.
 Product getProduct()
          Returns the product the ad is targeting.
 int hashCode()
          Returns a hash code based on the contained product.
 boolean isGeneric()
          Returns true if the ad is generic and false if the ad is targeted.
protected  void readWithLock(se.sics.isl.transport.TransportReader reader)
          Reads the product from the reader.
 void setProduct(Product product)
          Sets the product for the ad.
 java.lang.String toString()
          Creates a string that displays whether the ad is generic and the product, if targeted.
protected  void writeWithLock(se.sics.isl.transport.TransportWriter writer)
          Writes the product to the writer.
 
Methods inherited from class edu.umich.eecs.tac.props.AbstractTransportable
getTransportName, isLocked, lock, lockCheck, read, write
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Ad

public Ad()
Creates a generic ad.


Ad

public Ad(Product product)
Creates a targeted ad if product is not null. The ad is generic if the product is null.

Parameters:
product - the targeting product. The ad is generic if the product is null.
Method Detail

isGeneric

public final boolean isGeneric()
Returns true if the ad is generic and false if the ad is targeted.

Returns:
true if the ad is generic and false if the ad is targeted.

getProduct

public final Product getProduct()
Returns the product the ad is targeting. The product is null if the ad is generic.

Returns:
the product the ad is targeting. The product is null if the ad is generic.

setProduct

public final void setProduct(Product product)
                      throws java.lang.IllegalStateException
Sets the product for the ad. Setting the product to null sets the ad as generic.

Parameters:
product - the product for the ad. Setting the product to null sets the ad as generic.
Throws:
java.lang.IllegalStateException - if the ad is locked.

readWithLock

protected final void readWithLock(se.sics.isl.transport.TransportReader reader)
                           throws java.text.ParseException
Reads the product from the reader.

Specified by:
readWithLock in class AbstractTransportable
Parameters:
reader - the reader to read data from.
Throws:
java.text.ParseException - if there was an exception reading the product.

writeWithLock

protected final void writeWithLock(se.sics.isl.transport.TransportWriter writer)
Writes the product to the writer.

Specified by:
writeWithLock in class AbstractTransportable
Parameters:
writer - the writer to write data to.

toString

public final java.lang.String toString()
Creates a string that displays whether the ad is generic and the product, if targeted.

Overrides:
toString in class java.lang.Object
Returns:
a string that displays whether the ad is generic and the product, if targeted.

equals

public final boolean equals(java.lang.Object o)
Returns true if the object is an Ad and has the same product or lack thereof.

Overrides:
equals in class java.lang.Object
Parameters:
o - the object to compare.
Returns:
true if the object is an Ad and has the same product or lack thereof.

hashCode

public final int hashCode()
Returns a hash code based on the contained product.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code based on the contained product.


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