Package com.jbidwatcher.util.xml

Examples of com.jbidwatcher.util.xml.XMLElement


   */
  public void fromXML(XMLInterface curElement) {
    Iterator<XMLInterface> logStep = curElement.getChildren();

    while(logStep.hasNext()) {
      XMLElement curEntry = (XMLElement)logStep.next();

      if(curEntry.getTagName().equals("entry")) {
        long msgtime = System.currentTimeMillis();
        String msg = "Nothing has happened.";
        int curCount = Integer.parseInt(curEntry.getProperty("COUNT"));

        Iterator<XMLInterface> entryStep = curEntry.getChildren();
        while(entryStep.hasNext()) {
          XMLElement entryField = (XMLElement)entryStep.next();
          if(entryField.getTagName().equals("message")) msg = entryField.getContents();
          if(entryField.getTagName().equals("date")) msgtime = Long.parseLong(entryField.getContents());
        }

        EventStatus newEvent = new EventStatus(msg, new Date(msgtime), mEntryId, mIdentifier, mTitle);
        newEvent.setRepeatCount(curCount);
        newEvent.saveDB();
View Full Code Here


  }

  public XMLElement toXML() {
    if(mAllEvents.isEmpty()) return null;

    XMLElement xmlLog = new XMLElement("log");

    for (EventStatus curEvent : mAllEvents) {
      XMLElement xmlResult = new XMLElement("entry");
      xmlResult.setProperty("count", Integer.toString(curEvent.getRepeatCount()));

      XMLElement xmsg = new XMLElement("message");
      xmsg.setContents(curEvent.getMessage());
      xmlResult.addChild(xmsg);

      if (curEvent.getLoggedAt() != null) {
        XMLElement xdate = new XMLElement("date");
        xdate.setContents(Long.toString(curEvent.getLoggedAt().getTime()));
        xmlResult.addChild(xdate);
      }

      xmlLog.addChild(xmlResult);
    }
View Full Code Here

    AuctionServerInterface defaultServer = getServer();
    return defaultServer.getTime();
  }

  public XMLElement toXML() {
    XMLElement xmlResult = new XMLElement("auctions");
    XMLElement serverChild = new XMLElement("server");
    List<AuctionEntry> entryList = AuctionEntry.findAll();//TODO EntryCorral these?

    if (entryList == null || entryList.isEmpty()) return null;

    serverChild.setProperty("name", mServer.getName());

    int aucCount = 0;
    aucCount += entryList.size();

    for (AuctionEntry ae : entryList) {
      try {
        serverChild.addChild(ae.toXML());
      } catch (Exception e) {
        try {
        JConfig.log().handleException("Exception trying to save auction " + ae.getIdentifier() + " (" + ae.getTitle() + ") -- Not saving", e);
        } catch(Exception e2) {
          JConfig.log().handleException("Exception trying to save auction entry id " + ae.getId() + " -- Not saving", e);
View Full Code Here

  public void execute() { setLastRun(); fire(); }
  protected abstract void fire();

  /** @noinspection FeatureEnvy*/
  public XMLElement toXML() {
    XMLElement search = new XMLElement("search");

    search.setProperty("type", getTypeName());
    search.setProperty("id", Long.toString(getId()));

    XMLElement xname = new XMLElement("name");
    xname.setContents(getName());
    search.addChild(xname);

    XMLElement xsearch = new XMLElement("search");
    xsearch.setContents(getSearch());
    search.addChild(xsearch);

    XMLElement xperiod = new XMLElement("period");
    xperiod.setContents(Integer.toString(getPeriod()));
    search.addChild(xperiod);

    XMLElement xserver = new XMLElement("server");
    xserver.setContents(getServer());
    search.addChild(xserver);

    XMLElement xcurrency = new XMLElement("currency");
    xcurrency.setContents(getCurrency());
    search.addChild(xcurrency);

    XMLElement xlast = new XMLElement("last");
    xlast.setContents(Long.toString(getLastRun()));
    search.addChild(xlast);

    if(_enabled) {
      XMLElement xenabled = new XMLElement("enabled");
      xenabled.setEmpty();
      search.addChild(xenabled);
    }

    if(!_skip_deleted) {
      XMLElement xfinddeleted = new XMLElement("finddeleted");
      xfinddeleted.setEmpty();
      search.addChild(xfinddeleted);
    }

    XMLElement xcat = new XMLElement("category");
    if(_category == null) {
      xcat.setContents(getName());
    } else {
      xcat.setContents(_category);
    }
    search.addChild(xcat);

    _initialized = true;

View Full Code Here

  private MultiSnipeManager() {
    MQFactory.getConcrete("multisnipe_xml").registerListener(new MessageQueue.Listener() {
      public void messageAction(Object deQ) {
        String idXMLPair = (String)deQ;
        String identifier = idXMLPair.substring(0, idXMLPair.indexOf(' '));
        XMLElement element = new XMLElement();
        element.parseString(idXMLPair, identifier.length() + 1);
        MultiSnipe ms = MultiSnipe.loadFromXML(element);
        addAuctionToMultisnipe(identifier, ms);
      }
    });
View Full Code Here

    return toDelete.get(0).getDatabase().deleteBy("id IN (" + multisnipes + ")");
  }

  public XMLElement toXML() {
    XMLElement xmulti = new XMLElement("multisnipe");
    xmulti.setEmpty();
    xmulti.setProperty("subtractshipping", Boolean.toString(subtractShipping()));
    xmulti.setProperty("color", getColorString());
    xmulti.setProperty("default", getSnipeValue(null).fullCurrency());
    xmulti.setProperty("id", Long.toString(getIdentifier()));

    return xmulti;
  }
View Full Code Here

    super.fromXML(inXML);
    if(mSeller != null) mSeller.saveDB();
  }

  public XMLElement toXML() {
    XMLElement xmlResult = new XMLElement("info");

    addStringChild(xmlResult, "title");

    if(!getSellerName().equals("(unknown)") && mSeller != null) {
      XMLElement xseller = mSeller.toXML();
      xmlResult.addChild(xseller);
    }

    Date start = getStart();
    if(start != null) {
      XMLElement xstart = new XMLElement("start");
      xstart.setContents(Long.toString(start.getTime()));
      xmlResult.addChild(xstart);
    }

    Date end = getEnd();
    if(end != null) {
      XMLElement xend = new XMLElement("end");
      xend.setContents(Long.toString(end.getTime()));
      xmlResult.addChild(xend);
    }

    XMLElement xbidcount = new XMLElement("bidcount");
    xbidcount.setContents(Integer.toString(getNumBids()));
    xmlResult.addChild(xbidcount);

    XMLElement xinsurance = addCurrencyChild(xmlResult, "insurance");
    if(xinsurance != null) xinsurance.setProperty("optional", isInsuranceOptional() ?"true":"false");

    if(getCurBid() != null && !getCurBid().isNull()) {
      if (getCurBid().getCurrencyType() != Currency.US_DOLLAR) {
        addCurrencyChild(xmlResult, "usprice", Currency.US_DOLLAR);
      }
    }

    addCurrencyChild(xmlResult, "currently");
    addCurrencyChild(xmlResult, "shipping");
    addCurrencyChild(xmlResult, "buynow");
    addCurrencyChild(xmlResult, "buy_now_us");
    addCurrencyChild(xmlResult, "minimum");

    XMLElement xdutch = addBooleanChild(xmlResult, "dutch");
    if(xdutch != null) xdutch.setProperty("quantity", Integer.toString(getQuantity()));

    XMLElement xreserve = addBooleanChild(xmlResult, "reserve");
    if(xreserve != null) xreserve.setProperty("met", isReserveMet() ?"true":"false");

    addBooleanChild(xmlResult, "paypal");
    XMLElement xfixed = addBooleanChild(xmlResult, "fixed");
    if(xfixed != null && getQuantity() != 1) xfixed.setProperty("quantity", Integer.toString(getQuantity()));
    addBooleanChild(xmlResult, "private");

    addStringChild(xmlResult, "location");
    addStringChild(xmlResult, "highbidder");
View Full Code Here

    return saveDone;
  }

  public void loadSearches() {
    XMLElement xmlFile = new XMLElement(true);
    String loadFile = JConfig.queryConfiguration("search.savefile", "searches.xml");
    String oldLoad = loadFile;

    loadFile = Path.getCanonicalFile(loadFile, "jbidwatcher", true);

    if(!loadFile.equals(oldLoad)) {
      JConfig.setConfiguration("search.savefile", loadFile);
    }

    try {
      InputStreamReader isr = new InputStreamReader(new FileInputStream(loadFile));

      xmlFile.parseFromReader(isr);

      if(!xmlFile.getTagName().equals("searches")) {
        throw new XMLParseException(xmlFile.getTagName(), "SearchManager only recognizes <searches> tag!");
      } else {
        fromXML(xmlFile);
      }
    } catch(IOException ioe) {
      JConfig.log().logDebug("JBW: Failed to load saved searches, the search file is probably not there yet.");
View Full Code Here

      JConfig.log().handleException("JBW: Failed to load saved searches, file exists but can't be loaded!", e);
    }
  }

  public XMLElement toXML() {
    XMLElement allData = new XMLElement("searches");

    for (Searcher s : _searches) {
      XMLElement search = s.toXML();

      allData.addChild(search);
    }

    return allData;
View Full Code Here

  public int getFeedback() { return getInteger("feedback", 0); }
  public void setFeedback(int feedback) { setInteger("feedback", feedback); saveDB(); }

  @SuppressWarnings({"RefusedBequest"})
  public XMLElement toXML() {
    XMLElement xmlResult = new XMLElement("seller");
    XMLElement xseller = new XMLElement("name");
    XMLElement xfeedback = new XMLElement("feedback");
    XMLElement xpercentage = new XMLElement("feedback_percent");
    xseller.setContents(getSeller());
    xmlResult.addChild(xseller);

    xfeedback.setContents(Integer.toString(getFeedback()));
    xmlResult.addChild(xfeedback);

    String fp = getString("feedback_percentage");
    if(fp == null || fp.equals("100.00")) fp = "100";
    int decimal = fp.lastIndexOf('.');
    if(decimal != -1) {
      if(fp.substring(decimal+1).length() == 1) fp = fp + "0";
    }
    xpercentage.setContents(fp);
    xmlResult.addChild(xpercentage);

    return xmlResult;
  }
View Full Code Here

TOP

Related Classes of com.jbidwatcher.util.xml.XMLElement

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.