Package com.wesabe.xmlson

Examples of com.wesabe.xmlson.XmlsonArray


  public XmlsonObject present(InvestmentTxactionList investmentTxactions, Locale locale) {
    final XmlsonObject root = new XmlsonObject("investment-transaction-list");

    root.add(new XmlsonObject("count").addProperty("total", investmentTxactions.getTotalCount()));

    final XmlsonArray list = new XmlsonArray("investment-transactions");
    for (InvestmentTxactionListItem item : investmentTxactions) {
      final XmlsonObject investmentTxaction = investmentTxactionPresenter.present(item.getInvestmentTxaction(), locale);
      list.add(investmentTxaction);
    }
    root.add(list);

    return root;
  }
View Full Code Here


    this.sumOfMoneyPresenter = moneyPresenter;
  }
 
  public XmlsonObject present(ImmutableMap<Interval, MonetarySummaryWithSplits> summaries, Locale locale) {
    final XmlsonObject root = new XmlsonObject("interval-summary");
    final XmlsonArray array = new XmlsonArray("summaries");
   
    for (Map.Entry<Interval, MonetarySummaryWithSplits> summary : summaries.entrySet()) {
      final XmlsonObject item = new XmlsonObject("summary");
     
      final XmlsonObject interval = new XmlsonObject("interval");
      interval.addProperty("start", ISO_BASIC.print(summary.getKey().getStart()));
      interval.addProperty("end", ISO_BASIC.print(summary.getKey().getEnd()));
      item.add(interval);
      item.add(sumOfMoneyPresenter.present("spending", summary.getValue().getSpending(), locale));
      item.add(sumOfMoneyPresenter.present("earnings", summary.getValue().getEarnings(), locale));
      item.add(sumOfMoneyPresenter.present("net", summary.getValue().getNet(), locale));
     
      final XmlsonArray splits = new XmlsonArray("splits");
      for (Entry<Tag, MonetarySummary> entry : summary.getValue().getSplitSummaries().entrySet()) {
        final XmlsonObject splitsSummary = new XmlsonObject("split");
       
        final XmlsonObject tagName = new XmlsonObject("tag");
        tagName.addProperty("name", entry.getKey().toString());
        splitsSummary.add(tagName);
       
        splitsSummary.add(sumOfMoneyPresenter.present("spending", entry.getValue().getSpending(), locale));
        splitsSummary.add(sumOfMoneyPresenter.present("earnings", entry.getValue().getEarnings(), locale));
        splitsSummary.add(sumOfMoneyPresenter.present("net", entry.getValue().getNet(), locale));
        splits.add(splitsSummary);
      }
      item.add(splits);
     
      array.add(item);
    }
View Full Code Here

    } else {
      root.addNullProperty("check-number");
    }
   
    if (!txaction.getAttachments().isEmpty()) {
      final XmlsonArray attachments = new XmlsonArray("attachments");
      for (Attachment attachment : txaction.getAttachments()) {
        attachments.add(attachmentPresenter.present(attachment));
      }
      root.add(attachments);
    }
   
    root.addProperty("unedited-name", txaction.getUneditedName());
    root.addProperty("note", txaction.getNote());
   
    final XmlsonArray taggedAmounts = new XmlsonArray("tags");
    for (TaggedAmount taggedAmount : txaction.getTaggedAmounts()) {
      taggedAmounts.add(taggedAmountPresenter.present(taggedAmount, locale));
    }
    root.add(taggedAmounts);
    return root;
  }
View Full Code Here

    this.sumOfMoneyPresenter = moneyPresenter;
  }
 
  public XmlsonObject present(ImmutableMap<Tag, MonetarySummary> summaries, Locale locale) {
    final XmlsonObject root = new XmlsonObject("tag-summary");
    final XmlsonArray array = new XmlsonArray("summaries");
   
    for (Map.Entry<Tag, MonetarySummary> summary : summaries.entrySet()) {
      final XmlsonObject item = new XmlsonObject("summary");
     
      final XmlsonObject tag = new XmlsonObject("tag");
      tag.addProperty("name", summary.getKey().toString());
      item.add(tag);
      item.add(sumOfMoneyPresenter.present("spending", summary.getValue().getSpending(), locale));
      item.add(sumOfMoneyPresenter.present("earnings", summary.getValue().getEarnings(), locale));
      item.add(sumOfMoneyPresenter.present("net", summary.getValue().getNet(), locale));
     
      array.add(item);
     
    }
    root.add(array);
   
    return root;
View Full Code Here

    this.moneyPresenter = moneyPresenter;
  }
 
  public XmlsonObject present(ImmutableMap<Interval, Money> summaries, Locale locale) {
    final XmlsonObject root = new XmlsonObject("net-worth-summary");
    final XmlsonArray array = new XmlsonArray("summaries");
   
    for (Map.Entry<Interval, Money> summary : summaries.entrySet()) {
      final XmlsonObject item = new XmlsonObject("summary");
     
      final XmlsonObject interval = new XmlsonObject("interval");
      interval.addProperty("start", ISO_BASIC.print(summary.getKey().getStart()));
      interval.addProperty("end", ISO_BASIC.print(summary.getKey().getEnd()));
      item.add(interval);
      item.add(moneyPresenter.present("balance", summary.getValue(), locale));
     
      array.add(item);
    }
    root.add(array);
   
    return root;
  }
View Full Code Here

  public XmlsonObject present(InvalidStateException exception) {
    final XmlsonObject error = new XmlsonObject("error");
    error.addProperty("type", "validation");
   
    final XmlsonArray invalidValues = new XmlsonArray("invalid-values");
    for (InvalidValue invalidValue : exception.getInvalidValues()) {
      final XmlsonObject value = new XmlsonObject("invalid-value");
      value.addProperty("class", invalidValue.getBeanClass().getName());
      value.addProperty("field", invalidValue.getPropertyName());
      value.addProperty("message", invalidValue.getMessage());
      invalidValues.add(value);
    }
    error.add(invalidValues);
   
    return error;
  }
View Full Code Here

 
  public XmlsonObject present(TagHierarchy tagHierarchy, Locale locale) {
    final XmlsonObject root = new XmlsonObject("tag-hierarchy");
    root.add(sumOfMoneyPresenter.present("sum", tagHierarchy.getSum(), locale));
   
    final XmlsonArray nodes = new XmlsonArray("nodes");
    for (Node node : tagHierarchy.getChildren().values()) {
      nodes.add(present(node, locale));
    }
    root.add(nodes);
   
    return root;
  }
View Full Code Here

    root.add(tag);
   
    root.add(sumOfMoneyPresenter.present("sum", node.getSum(), locale));
   
    if (!node.getChildren().isEmpty()) {
      final XmlsonArray nodes = new XmlsonArray("nodes");
      for (Node child : node.getChildren().values()) {
        nodes.add(present(child, locale));
      }
      root.add(nodes);
    }
   
    return root;
View Full Code Here

  }

  public XmlsonObject present(AccountList accountList, Currency currency, Locale locale) {
    final XmlsonObject root = new XmlsonObject("account-list");

    final XmlsonArray accounts = new XmlsonArray("accounts");
    for (Account account : accountList) {
      final XmlsonObject accountNode;
      if (account instanceof InvestmentAccount) {
        accountNode = investmentAccountPresenter.present((InvestmentAccount)account, locale);
      } else {
        accountNode = accountPresenter.present(account, locale);       
      }
      accounts.add(accountNode);
    }
    root.add(accounts);

    final XmlsonArray groups = new XmlsonArray("account-groups");
    for (AccountGroup group : accountList.getAccountGroups()) {
      groups.add(accountGroupPresenter.present(group, currency, locale));
    }
    root.add(groups);

    root.add(
      moneyPresenter.present(
View Full Code Here

    final XmlsonObject root = new XmlsonObject("group");
    root.addProperty("name", group.getName());
    // REVIEW coda@wesabe.com -- May 21, 2009: Replace account group URI building once AccountGroupResource is written
    root.addProperty("uri", String.format("/account-groups/%s", group.getId()));
   
    final XmlsonArray accounts = new XmlsonArray("accounts");
    boolean hasTotal = false;
    for (Account account : group.getAccounts()) {
      accounts.add(accountReferencePresenter.present(account));
      if (account.hasBalance()) {
        hasTotal = true;
      }
    }
    root.add(accounts);
View Full Code Here

TOP

Related Classes of com.wesabe.xmlson.XmlsonArray

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.