Package org.infinispan.quickstart.compatibility.common

Examples of org.infinispan.quickstart.compatibility.common.SharesUpdate


   private void updateMarket() {
      float nextValue = nextValueOfShares();
      Date nextDate = getNextDate();
      String nextDateString = KEY_DATE_FORMAT.format(nextDate);

      SharesUpdate update = new SharesUpdate(nextDate, NAME_OF_SHARES, nextValue);
      //store an update in the cache
      cache.put(NAME_OF_SHARES + "_" + nextDateString, update);
      //also remember the last stored update
      cache.put(NAME_OF_SHARES + "_" + LAST_UPDATE_SUFFIX, update);
   }
View Full Code Here


         return;
      }

      String nameOfShares = args[1];
      try {
         SharesUpdate sharesUpdate = (SharesUpdate) getSharesUpdateViaRest(composeKey(nameOfShares, "last"));
         if (sharesUpdate != null) {
            console.printf("------------- %s -------------\n", nameOfShares);
            console.printf("Date:  %s\n", sharesUpdate.getDate().toString());
            console.printf("Value: %f USD\n", sharesUpdate.getValue());
         } else {
            console.printf("Last stock value for " + nameOfShares + " not found.\n");
         }
      } catch (Exception e) {
         e.printStackTrace();
View Full Code Here

         return;
      }

      try {
         //get last existing update and its date
         SharesUpdate lastUpdate = (SharesUpdate) getSharesUpdateViaRest(composeKey(stockName, "last"));
         //get all updates between last existing update and requested date in history
         List<String> stockHistoryKeys = getStockHistoryKeySet(stockName, lastUpdate.getDate(), toSeconds(maxHistoryArg), toSeconds(stepArg));

         float previous = 0.0f, current = 0.0f;

         console.printf("------------- History of %s -------------\n", stockName);
         for (String key : stockHistoryKeys) {
            SharesUpdate sharesUpdate = (SharesUpdate) getSharesUpdateViaRest(key);
            if (sharesUpdate != null) {
               current = sharesUpdate.getValue();
               console.printf("Date:  %s, value: %f USD (%s %+f%%)\n",
                              sharesUpdate.getDate().toString(),
                              current,
                              current > previous ? "increase" : "decrease",
                              computeIncreaseInPercent(previous, current));
            }
            previous = current;
View Full Code Here

TOP

Related Classes of org.infinispan.quickstart.compatibility.common.SharesUpdate

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.