avatar

984

Pass 'bid' and 'buy' amounts as strings, so the Bean/XMLification doesn't die, as it does with Currency values under random JRE's. (HateHateHate XMLEncoder and setPersistenceDelegate. SO broken! :( ) by mrs, 22 Jul, 2009 10:26 AM
Diff this changeset:
AuctionBuy.java
cyberfox  package com.jbidwatcher.auction;
cyberfox  
cyberfox  /*
cyberfox   * Copyright (c) 2000-2007, CyberFOX Software, Inc. All Rights Reserved.
cyberfox   *
cyberfox   * Developed by mrs (Morgan Schweers)
cyberfox   */
cyberfox  
cyberfox  import com.jbidwatcher.util.Currency;
cyberfox 10 import com.jbidwatcher.auction.server.AuctionServer;
cyberfox 11 
cyberfox 12 public class AuctionBuy extends AuctionActionImpl {
mrs      13   public AuctionBuy() { super(); }
cyberfox 14   public AuctionBuy(String id, Currency amount, int quantity) {
mrs      15     super(id, amount.fullCurrency(), quantity);
cyberfox 16   }
cyberfox 17 
cyberfox 18   public AuctionBuy(AuctionEntry ae, Currency amount, int quantity) {
mrs      19     super(ae.getIdentifier(), amount.fullCurrency(), quantity);
cyberfox 20   }
cyberfox 21 
cyberfox 22   protected int execute(AuctionEntry ae, Currency curr, int quant) {
cyberfox 23     return ae.buy(quant);
cyberfox 24   }
cyberfox 25 
cyberfox 26   public String getBidResult(Currency bidAmount, int bidResult) {
cyberfox 27     String bidResultString;
cyberfox 28 
cyberfox 29     switch (bidResult) {
cyberfox 30       case AuctionServerInterface.BID_ERROR_UNKNOWN:
mrs      31         bidResultString = "Purchasing apparently failed for an unknown reason.  Check the auction in the browser, to see if it went through anyway.";
cyberfox 32         break;
mrs      33       case com.jbidwatcher.auction.AuctionServerInterface.BID_ERROR_ENDED:
cyberfox 34       case AuctionServerInterface.BID_ERROR_CANNOT:
cyberfox 35         bidResultString = "Purchasing apparently failed, as the auction cannot be bought from anymore (probably ended)!";
cyberfox 36         break;
cyberfox 37       case AuctionServerInterface.BID_ERROR_BANNED:
cyberfox 38         bidResultString = "Your purchase failed, as you are disallowed from buying this seller's items.";
cyberfox 39         break;
mrs      40       case com.jbidwatcher.auction.AuctionServerInterface.BID_ERROR_CONNECTION:
cyberfox 41         bidResultString = "Purchase failed due to connection problem.  Probably a timeout trying to reach eBay.";
cyberfox 42         break;
cyberfox 43       case AuctionServer.BID_ERROR_AUCTION_GONE:
cyberfox 44         bidResultString = "Your purchase failed because the item was removed from JBidwatcher before it executed.";
cyberfox 45         break;
cyberfox 46       case AuctionServer.BID_ERROR_NOT_BIN:
cyberfox 47         bidResultString = "You cannot purchase this item, it is not a Buy It Now item.";
cyberfox 48         break;
cyberfox 49       case AuctionServer.BID_BOUGHT_ITEM:
cyberfox 50         bidResultString = "Congratulations!  You successfully bought it!";
cyberfox 51         break;
cyberfox 52       default:
cyberfox 53         return super.getBidResult(bidAmount, bidResult);
cyberfox 54     }
cyberfox 55     return bidResultString;
cyberfox 56   }
cyberfox 57 }

Check out the code: svn co jbidwatcher/trunk/src/com/jbidwatcher/auction/AuctionBuy.java