
/**
* called by SAX2Internal when it has found the product name
* @param name the product name
*/
public void setProductName(String name)
{
productName = name;
}
/**
* called by SAX2Internal when it has found a price
* @param vendor vendor’s name
* @param price price proposal
* @param delivery delivery time proposal
*/
public void compare(String vendor,double price,int delivery)
{
if(delivery <= targetDelivery)
{
if(bestPrice > price)
{
bestPrice = price;
vendorName = vendor;
proposedDelivery = delivery;
}
}
}
/**
* property accessor: vendor’s name
* @return the vendor with the cheapest offer so far
*/
public String getVendor()
{
return vendorName;
}
252
Chapter 8: Alternative ...