Package com.jbidwatcher.util

Examples of com.jbidwatcher.util.Currency


    if (curPrice == null || curPrice.isNull()) return getBuyNow();
    return curPrice;
  }

  public Currency getCurrentUSPrice() {
    Currency curPrice = getCurBid();
    if (curPrice == null || curPrice.isNull()) return getBuyNowUS();
    return getUSCurBid();
  }
View Full Code Here


              }
            }
            if(myMostRecentRow != -1) {
              String newCurrency = t.getCell(1, myMostRecentRow);
              if (newCurrency != null) {
                Currency highBid = Currency.getCurrency(newCurrency);
                try {
                  if (!ae.isBidOn() || ae.getBid().less(highBid)) {
                    ae.setBid(highBid);
                    ae.setBidQuantity(bidCount);
                    ae.saveDB();
View Full Code Here

  public void setErrorPage(StringBuffer page) { mLastErrorPage = page; }
  public StringBuffer getErrorPage() { return mLastErrorPage; }

  public Currency getShippingWithInsurance() {
    Currency ship = getShipping();
    if(ship == null || ship.isNull())
      return Currency.NoValue();
    else {
      ship = addInsurance(ship);
    }
    return ship;
View Full Code Here

    }
    return ship;
  }

  public boolean isShippingOverridden() {
    Currency ship = getMonetary("shipping");
    return ship != null && !ship.isNull();
  }
View Full Code Here

  private static Currency zeroIndianRupee = new Currency("INR0.00");
  private static Currency zeroTaiwanese = new Currency("NTD0.00");
  private static Currency zeroCanadian = new Currency("CAD0.00");

  Currency getMinimumBidIncrement(Currency currentBid, int bidCount) {
    Currency correctedValue = currentBid;
    Currency zeroIncrement = zeroDollars;
    Currency[][] rightTable;

    switch (currentBid.getCurrencyType()) {
      //  Default to USD, so we don't freak if we're passed a bad
      //  value.  We'll get the wrong answer, but we won't thrash.
      default:
        correctedValue = zeroDollars;
        rightTable = us_incrementTable;
        break;
      case Currency.US_DOLLAR:
        rightTable = us_incrementTable;
        break;
      case Currency.UK_POUND:
        rightTable = uk_incrementTable;
        zeroIncrement = zeroPounds;
        break;
      case Currency.FR_FRANC:
        rightTable = fr_incrementTable;
        zeroIncrement = zeroFrancs;
        break;
      case Currency.CH_FRANC:
        rightTable = ch_incrementTable;
        zeroIncrement = zeroSwissFrancs;
        break;
      case Currency.EURO:
        rightTable = eu_incrementTable;
        zeroIncrement = zeroEuros;
        break;
      case Currency.TW_DOLLAR:
        rightTable = tw_incrementTable;
        zeroIncrement = zeroTaiwanese;
        break;
      case Currency.CAN_DOLLAR:
        rightTable = ca_incrementTable;
        zeroIncrement = zeroCanadian;
        break;
      case Currency.AU_DOLLAR:
        rightTable = au_incrementTable;
        zeroIncrement = zeroAustralian;
        break;
      case Currency.IND_RUPEE:
        rightTable = ir_incrementTable;
        zeroIncrement = zeroIndianRupee;
        break;
    }

    if (bidCount == 0) return zeroIncrement;

    for (Currency[] aRightTable : rightTable) {
      Currency endValue = aRightTable[0];
      Currency incrementValue = aRightTable[1];

      //  Sentinel.  If we reach the end, return the max.
      if (endValue == null || endValue.isNull()) return incrementValue;

      try {
View Full Code Here

  public TableRowSorter<TableModel> getTableSorter() { return sorter; }
  public JTable getTable() { return _table; }

  private static Currency addUSD(Currency inCurr, AuctionEntry ae) {
    boolean newCurrency = (inCurr == null || inCurr.isNull());
    Currency currentUSPrice = ae.getCurrentUSPrice();
    try {
      if(ae.getShippingWithInsurance().isNull()) {
        if(newCurrency) {
          return currentUSPrice;
        }
        return inCurr.add(currentUSPrice);
      }

      if(newCurrency) {
        inCurr = currentUSPrice.add(Currency.convertToUSD(currentUSPrice, ae.getCurrentPrice(), ae.getShippingWithInsurance()));
      } else {
        inCurr = inCurr.add(currentUSPrice.add(Currency.convertToUSD(currentUSPrice, ae.getCurrentPrice(), ae.getShippingWithInsurance())));
      }
    } catch(Currency.CurrencyTypeException cte) {
      JConfig.log().handleException("This should have been cleaned up.", cte);
    }
    return inCurr;
View Full Code Here

    return inCurr;
  }

  protected String sum(int[] rowList) {
    boolean approx = false, i18n = true;
    Currency accum = null;
    Currency withShipping = null;
    Currency withRealShipping = null;
    Currency realAccum = null;

    try {
      for (int aRowList : rowList) {
        AuctionEntry ae2;
        try {
          ae2 = (AuctionEntry) _table.getValueAt(aRowList, -1);
        } catch (ClassCastException cce) {
          ae2 = null;
        } catch (IndexOutOfBoundsException bounds) {
          ae2 = null;
          approx = true;
        }
        if (ae2 != null) {
          Currency currentUSPrice = ae2.getCurrentUSPrice();

          if (accum == null) {
            accum = currentUSPrice;
            realAccum = getBestBidValue(ae2);
            withShipping = addUSD(withShipping, ae2);
            withRealShipping = addNonUSD(withRealShipping, ae2);
          } else {
            if (!currentUSPrice.isNull() && !accum.isNull() && currentUSPrice.getCurrencyType() != Currency.NONE) {
              accum = accum.add(currentUSPrice);
              withShipping = addUSD(withShipping, ae2);

              //  If we're still trying to do the internationalization
              //  thing, then try to keep track of the 'real' total.
View Full Code Here

  private StringBuffer setupSnipePage(String auctionId) {
    AuctionEntry ae = AuctionEntry.findByIdentifier(auctionId);

    if (ae == null) return (null);
    Currency minBid;

    try {
      minBid = ae.getCurBid().add(ae.getServer().getMinimumBidIncrement(ae.getCurBid(), ae.getNumBidders()));
    } catch (Currency.CurrencyTypeException ignored) {
      minBid = ae.getCurBid();
    }

    JHTMLOutput jho = new JHTMLOutput("Prepare snipe",
        new JHTMLDialog("Snipe", "./activateSnipe", "GET",
            findIDString, auctionId, "snipe",
            "Enter snipe amount, with no currency symbols.", findAmountString, 20,
            minBid.getValueString()) +
            messageFinisher);

    return jho.getStringBuffer();
  }
View Full Code Here

    return checkError(AuctionTransformer.outputHTML(JConfig.queryConfiguration("savefile", "auctions.xml")));
  }

  public StringBuffer doSnipe(String auctionId, String snipeAmount) {
    AuctionEntry ae = AuctionEntry.findByIdentifier(auctionId);
    Currency snipeValue = Currency.getCurrency(ae.getCurBid().fullCurrencyName(), snipeAmount);

    JConfig.log().logDebug("Remote-controlled snipe activated against auction " + auctionId + " for " + snipeValue);
    ae.prepareSnipe(snipeValue);
    MQFactory.getConcrete("redraw").enqueue(ae.getIdentifier());
View Full Code Here


  /** Key methods **/
  public String getId() { return entry.getIdentifier(); }
  public Currency getCurrentBid() {
    Currency rval = entry.getUSCurBid();
    if(rval.getValue() == 0.0 && rval.getCurrencyType() == Currency.US_DOLLAR) {
      return entry.getCurrentUSPrice();
    }
    return rval;
  }
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.