コード例 #1
0
  public void compose(IXMLWriter writer, AtomFeed feed, boolean htmlPretty) throws Exception {
    this.htmlPretty = htmlPretty;
    xml = writer;
    xml.setDefaultNamespace(ATOM_NS);

    xml.open(ATOM_NS, "feed");
    if (feed.getTitle() != null) xml.element(ATOM_NS, "title", feed.getTitle());
    if (feed.getId() != null) xml.element(ATOM_NS, "id", feed.getId());
    for (String n : feed.getLinks().keySet()) {
      xml.attribute("href", feed.getLinks().get(n));
      xml.attribute("rel", n);
      xml.element(ATOM_NS, "link", null);
    }
    if (feed.getTotalResults() != null) {
      xml.setDefaultNamespace("http://purl.org/atompub/tombstones/1.0");
      xml.element("totalResults", feed.getTotalResults().toString());
      xml.setDefaultNamespace(ATOM_NS);
    }
    if (feed.getUpdated() != null) xml.element(ATOM_NS, "updated", feed.getUpdated().toString());
    if (feed.getAuthorName() != null || feed.getAuthorUri() != null) {
      xml.open(ATOM_NS, "author");
      if (feed.getAuthorName() != null) xml.element(ATOM_NS, "name", feed.getAuthorName());
      if (feed.getAuthorUri() != null) xml.element(ATOM_NS, "uri", feed.getAuthorUri());
      xml.close(ATOM_NS, "author");
    }
    for (AtomCategory cat : feed.getTags()) {
      xml.attribute("scheme", cat.getScheme());
      xml.attribute("term", cat.getTerm());
      if (!Utilities.noString(cat.getLabel())) xml.attribute("label", cat.getLabel());
      xml.element("category", null);
    }

    for (AtomEntry<? extends Resource> e : feed.getEntryList()) composeEntry(e);
    xml.close(ATOM_NS, "feed");
  }
コード例 #2
0
  public void compose(IXMLWriter writer, List<AtomCategory> tags, boolean htmlPretty)
      throws Exception {
    this.htmlPretty = htmlPretty;
    xml = writer;
    xml.setDefaultNamespace(FHIR_NS);

    xml.open(FHIR_NS, "taglist");
    for (AtomCategory cat : tags) {
      xml.attribute("scheme", cat.getScheme());
      xml.attribute("term", cat.getTerm());
      if (!Utilities.noString(cat.getLabel())) xml.attribute("label", cat.getLabel());
      xml.element("category", null);
    }
    xml.close(FHIR_NS, "taglist");
  }
コード例 #3
0
  private <T extends Resource> void composeEntry(AtomEntry<T> entry) throws Exception {
    AtomEntry<T> e = entry;
    if (entry.isDeleted()) {
      xml.setDefaultNamespace("http://purl.org/atompub/tombstones/1.0");
      xml.attribute("ref", entry.getId());
      xml.attribute("when", entry.getUpdated().toString());
      xml.open("deleted-entry");
      for (String name : entry.getLinks().keySet()) {
        xml.attribute("href", entry.getLinks().get(name));
        xml.attribute("rel", name);
        xml.element("link", null);
      }
      //	    if (entry.getoriginalId <> "") then
      //	    begin
      //	      xml.open("source");
      //	      xml.element("id", entry.originalId);
      //	      xml.close("source");
      //	    end;
      if (entry.getAuthorUri() != null || entry.getAuthorName() != null) {
        xml.open("by");
        if (entry.getAuthorName() != null) xml.element("name", entry.getAuthorName());
        if (entry.getAuthorUri() != null) xml.element("uri", entry.getAuthorUri());
        xml.close("by");
      }
      xml.close("deleted-entry");
      xml.setDefaultNamespace(ATOM_NS);
    } else {
      xml.setDefaultNamespace(ATOM_NS);
      xml.open("entry");
      if (e.getTitle() != null) xml.element(ATOM_NS, "title", e.getTitle());
      if (e.getId() != null) xml.element(ATOM_NS, "id", e.getId());
      for (String n : e.getLinks().keySet()) {
        xml.attribute("href", e.getLinks().get(n));
        xml.attribute("rel", n);
        xml.element(ATOM_NS, "link", null);
      }
      if (e.getUpdated() != null) xml.element(ATOM_NS, "updated", e.getUpdated().toString());

      if (entry.getAuthorUri() != null || entry.getAuthorName() != null) {
        xml.open("author");
        if (entry.getAuthorName() != null) xml.element("name", entry.getAuthorName());
        if (entry.getAuthorUri() != null) xml.element("uri", entry.getAuthorUri());
        xml.close("author");
      }
      for (AtomCategory cat : entry.getTags()) {
        xml.attribute("scheme", cat.getScheme());
        xml.attribute("term", cat.getTerm());
        if (!Utilities.noString(cat.getLabel())) xml.attribute("label", cat.getLabel());
        xml.element("category", null);
      }
      if (e.getPublished() != null) xml.element(ATOM_NS, "published", e.getPublished().toString());

      xml.attribute("type", "text/xml");
      xml.open(ATOM_NS, "content");
      xml.setDefaultNamespace(FHIR_NS);
      if (entry.getResource() instanceof Binary)
        composeBinary("Binary", (Binary) entry.getResource());
      else composeResource(entry.getResource());
      xml.setDefaultNamespace(ATOM_NS);
      xml.close(ATOM_NS, "content");

      if (e.getSummary() != null) {
        xml.attribute("type", "xhtml");
        xml.open(ATOM_NS, "summary");
        xml.namespace(XhtmlComposer.XHTML_NS, null);
        boolean oldPretty = xml.isPretty();
        xml.setPretty(htmlPretty);
        new XhtmlComposer().compose(xml, e.getSummary());
        xml.setPretty(oldPretty);
        xml.close(ATOM_NS, "summary");
      }
      xml.close("entry");
    }
  }
コード例 #4
0
 private boolean hasTag(String scheme, String term) {
   for (AtomCategory tag : getTags()) {
     if (scheme.equals(tag.getScheme()) && term.equals(tag.getTerm())) return true;
   }
   return false;
 }