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); return ms; }
private void loadXMLFromFile(String loadFile, XMLElement xmlFile) throws IOException { InputStreamReader isr = new InputStreamReader(new FileInputStream(loadFile)); MQFactory.getConcrete("splash").enqueue("WIDTH " + MAX_PERCENT); MQFactory.getConcrete("splash").enqueue("SET " + MAX_PERCENT / 2); xmlFile.parseFromReader(isr); MQFactory.getConcrete("splash").enqueue("SET " + MAX_PERCENT); String formatVersion = xmlFile.getProperty("FORMAT", "0101"); XMLElement auctionsXML = xmlFile.getChild("auctions"); JConfig.setConfiguration("savefile.format", formatVersion); // set the width of the splash progress bar based on the number // of auctions that will be loaded! if (auctionsXML == null) { throw new XMLParseException( xmlFile.getTagName(), "AuctionsManager requires an <auctions> tag!"); } String auctionQuantity = auctionsXML.getProperty("COUNT", null); int auctionTotal = 0; if (auctionQuantity != null) { auctionTotal = Integer.parseInt(auctionQuantity); MQFactory.getConcrete("splash").enqueue("SET 0"); MQFactory.getConcrete("splash").enqueue("WIDTH " + auctionTotal); } AuctionServerManager.setEntryManager(this); AuctionServerManager.getInstance().fromXML(auctionsXML); AuctionStats as = AuctionServerManager.getInstance().getStats(); // TODO -- Do something more valuable than just notify, when the auction counts are off. int savedCount = Integer.parseInt(JConfig.queryConfiguration("last.auctioncount", "-1")); if (as != null) { if (as.getCount() != auctionTotal || (savedCount != -1 && as.getCount() != savedCount)) { MQFactory.getConcrete("Swing").enqueue("NOTIFY Failed to load all auctions."); } } }
protected void handleTag(int i, XMLElement curElement) { switch (i) { case 0: // Title setString(infoTags[i], curElement.decodeString(curElement.getContents())); break; case 1: // Seller name if (curElement.getChild("name") == null) { setSellerName(curElement.getContents()); } else { mSeller = Seller.newFromXML(curElement); } break; case 2: // High bidder name case 18: // Location of item setString(infoTags[i], curElement.getContents()); break; case 3: // Bid count setInteger(infoTags[i], Integer.parseInt(curElement.getContents())); break; case 4: // Start date case 5: // End date setDate(infoTags[i], new Date(Long.parseLong(curElement.getContents()))); break; case 6: // Current price case 11: // Shipping cost 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); switch (i) { case 13: setDefaultCurrency(amount); break; case 6: if (amount.getCurrencyType() == Currency.US_DOLLAR) { setMonetary("us_cur", amount); setString("currency", amount.fullCurrencyName()); } setDefaultCurrency(amount); break; case 12: String optional = curElement.getProperty("OPTIONAL"); setBoolean("insurance_optional", optional == null || (optional.equals("true"))); break; } break; case 7: // Is a dutch auction? case 8: // Is a reserve auction? case 9: // Is a private auction? case 15: // Fixed price case 17: // PayPal accepted setBoolean(infoTags[i], true); if (i == 7 || i == 15) { String quant = curElement.getProperty("QUANTITY"); if (quant == null) { setInteger("quantity", 1); } else { setInteger("quantity", Integer.parseInt(quant)); } } else if (i == 8) { setBoolean("reserve_met", "true".equals(curElement.getProperty("MET"))); } break; case 19: // Feedback score String feedback = curElement.getContents(); if (mSeller == null) mSeller = new Seller(); if (feedback != null) mSeller.setFeedback(Integer.parseInt(feedback)); break; case 20: // Positive feedback percentage (w/o the % sign) String percentage = curElement.getContents(); if (mSeller == null) mSeller = new Seller(); mSeller.setPositivePercentage(percentage); break; case 21: // Seller info block mSeller = Seller.newFromXML(curElement); break; default: break; // commented out for FORWARDS compatibility. // throw new RuntimeException("Unexpected value when handling AuctionInfo tags!"); } }