Esempio n. 1
0
  /**
   * Prepares the email subject to send to the user
   *
   * @param subscribedCompanies
   * @return
   */
  private String buildSubjectCompanies(List<Company> subscribedCompanies) {
    StringBuffer buff = new StringBuffer();

    for (Company company : subscribedCompanies) {
      StockInfo data = company.getStockInfo();
      if (data != null) {
        buff.append(String.format("Company: %s \n", company.getName()));
        buff.append("\n");

        buff.append(
            String.format(
                "Last: %s \n", (data.getLastQuotation() == null ? "" : data.getLastQuotation())));
        buff.append(String.format("Time: %s \n", (data.getTime() == null ? "" : data.getTime())));
        buff.append(
            String.format(
                "Variation: %s \n", (data.getVariation() == null ? "" : data.getVariation())));
        buff.append(
            String.format(
                "Quantity: %s \n", (data.getQuantity() == null ? "" : data.getQuantity())));
        buff.append(
            String.format("Maximum: %s \n", (data.getMaximum() == null ? "" : data.getMaximum())));
        buff.append(
            String.format("Minimum: %s \n", (data.getMinimum() == null ? "" : data.getMinimum())));
        buff.append(
            String.format(
                "Purchase: %s \n", (data.getPurchase() == null ? "" : data.getPurchase())));
        buff.append(String.format("Sell: %s \n", (data.getSell() == null ? "" : data.getSell())));

        buff.append("------------------------------------------------------\n");
      } else {
        logger.info(
            String.format("buildSubjectCompanies no StockInfo for company %s", company.getName()));
      }
    }

    return buff.toString();
  }