Package com.jbidwatcher.util

Examples of com.jbidwatcher.util.Currency


  }

  public static MultiSnipe loadFromXML(XMLElement curElement) {
    String identifier = curElement.getProperty("ID");
    String bgColor = curElement.getProperty("COLOR");
    Currency defaultSnipe = Currency.getCurrency(curElement.getProperty("DEFAULT"));
    boolean subtractShipping = curElement.getProperty("SUBTRACTSHIPPING", "false").equals("true");

    MultiSnipe ms = MultiSnipe.findFirstBy("identifier", identifier);
    if(ms == null) {
      ms = new MultiSnipe(bgColor, defaultSnipe, Long.parseLong(identifier), subtractShipping);
View Full Code Here


  }

  public AuctionActionImpl() { }

  public String activate() {
    Currency amount = Currency.getCurrency(mAmount);
    AuctionEntry entry = (AuctionEntry) EntryCorral.getInstance().takeForWrite(mIdentifier);
    try {
      if (entry == null) {
        mResult = AuctionServer.BID_ERROR_AUCTION_GONE;
        return getBidResult(amount, mResult);
View Full Code Here

      case 12: //  Insurance cost
      case 13: //  Buy Now price
      case 22: //  Buy Now US price
      case 14: //  Current US price
      case 16: //  Minimum price/bid
        Currency amount = Currency.getCurrency(curElement.getProperty("CURRENCY"), curElement.getProperty("PRICE"));
        setMonetary(infoTags[i], amount, i != 22 && i != 14);
        switch(i) {
          case 13:
            setDefaultCurrency(amount);
            break;
          case 6:
            if (amount.getCurrencyType() == Currency.US_DOLLAR) {
              setMonetary("us_cur", amount, false);
              setString("currency", amount.fullCurrencyName());
            }
            setDefaultCurrency(amount);
            break;
          case 12:
            String optional = curElement.getProperty("OPTIONAL");
View Full Code Here

  public String getItemLocation() { return getString("itemLocation", ""); }

  public boolean isComplete() { return getBoolean("ended"); }

  public Currency getBestPrice() {
    Currency currentPrice = getCurBid();
    if (currentPrice == null || currentPrice.isNull()) {
      currentPrice = getBuyNow();
    }
    return currentPrice;
  }
View Full Code Here

     * will never be added to the items list.
     */
    if (mLoaded) {
      AuctionServerInterface newServer = (AuctionServerInterface) info.getServer();
      if(newServer != null) setServer(newServer);
      Currency currentPrice = info.getBestPrice();
      setDate("last_updated_at", new Date());
      setDefaultCurrency(currentPrice);
      saveDB();
      notifyObservers(ObserverMode.AFTER_CREATE);
      updateHighBid();
View Full Code Here

   * increment over the current high bid.  Returns false otherwise.
   */
  public boolean isSnipeValid() {
    if(getSnipe() == null) return false;

    Currency minIncrement = getServer().getMinimumBidIncrement(getCurBid(), getNumBidders());
    boolean rval = false;

    try {
      if(getSnipe().getAmount().getValue() >= getCurBid().add(minIncrement).getValue()) {
        rval = true;
View Full Code Here

  private void checkHighBidder() {
    int numBidders = getNumBidders();

    if(numBidders > 0) {
      if(isBidOn() && isPrivate()) {
        Currency curBid = getCurBid();
        try {
          if(curBid.less(getBid())) setWinning(true);
        } catch(Currency.CurrencyTypeException cte) {
          /* Should never happen...?  */
          JConfig.log().handleException("This should never happen (bad Currency at this point!).", cte);
        }
        if(curBid.equals(getBid())) {
          setWinning(numBidders == 1);
          //  winning == false means that there are multiple bidders, and the price that
          //  two (this user, and one other) bid are exactly the same.  How
          //  do we know who's first, given that it's a private auction?
          //
View Full Code Here

    switch(tagId) {
      case 0//  Get the general auction information
        //  TODO -- What if it's already in the database?
        break;
      case 1//  Get bid info
        Currency bidAmount = Currency.getCurrency(curElement.getProperty("CURRENCY"),
                                          curElement.getProperty("PRICE"));
        setBid(bidAmount);
        setBidQuantity(Integer.parseInt(curElement.getProperty("QUANTITY")));
        if(curElement.getProperty("WHEN", null) != null) {
          mBidAt = Long.parseLong(curElement.getProperty("WHEN"));
        }
        break;
      case 2//  Get the snipe info together
        Currency snipeAmount = Currency.getCurrency(curElement.getProperty("CURRENCY"),
                                            curElement.getProperty("PRICE"));
        prepareSnipe(snipeAmount, Integer.parseInt(curElement.getProperty("QUANTITY")));
        mSnipeAt = Long.parseLong(curElement.getProperty("SECONDSPRIOR"));
        break;
      case 3:
        setComplete(true);
        break;
      case 4:
        setInvalid();
        break;
      case 5:
        setComment(curElement.getContents());
        break;
      case 6:
        mEntryEvents = new EventLogger(getIdentifier(), getId(), getTitle());
        mEntryEvents.fromXML(curElement);
        break;
      case 7:
        MQFactory.getConcrete("multisnipe_xml").enqueue(getIdentifier() + " " + curElement.toString());
        break;
      case 8:
        Currency shipping = Currency.getCurrency(curElement.getProperty("CURRENCY"),
                                         curElement.getProperty("PRICE"));
        setShipping(shipping);
        break;
      case 9:
        setCategory(curElement.getContents());
View Full Code Here

   *
   * @return The result of the 'Buy' attempt.
   */
  public int buy(int quant) {
    int rval = AuctionServerInterface.BID_ERROR_NOT_BIN;
    Currency bin = getBuyNow();
    if(bin != null && !bin.isNull()) {
      setBid(getBuyNow());
      setBidQuantity(quant);
      mBidAt = System.currentTimeMillis();
      JConfig.log().logDebug("Buying " + quant + " item[s] of (" + getIdentifier() + ")-" + getTitle());
      rval = getServer().buy(getIdentifier(), quant);
View Full Code Here

   * Check current price, and fall back to buy-now price if 'current' isn't set.
   *
   * @return - The current price, or the buy now if current isn't set.
   */
  public Currency getCurrentPrice() {
    Currency curPrice = getCurBid();
    if (curPrice == null || curPrice.isNull()) return getBuyNow();
    return curPrice;
  }
View Full Code Here

TOP

Related Classes of com.jbidwatcher.util.Currency

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.