Exemplo n.º 1
0
    public Element toXml(Document doc, Stack stack) {
      Element syllabus = doc.createElement("syllabus");

      if (stack.isEmpty()) {
        doc.appendChild(syllabus);
      } else {
        ((Element) stack.peek()).appendChild(syllabus);
      }

      stack.push(syllabus);

      syllabus.setAttribute("id", m_id);
      syllabus.setAttribute("subject", m_data.getTitle());
      syllabus.setAttribute("body", m_data.getAsset());

      m_properties.toXml(doc, stack);

      stack.pop();

      return syllabus;
    }
    /** @inheritDoc */
    public Element toXml(Document doc, Stack stack) {
      Element digest = doc.createElement("digest");

      if (stack.isEmpty()) {
        doc.appendChild(digest);
      } else {
        ((Element) stack.peek()).appendChild(digest);
      }

      stack.push(digest);

      digest.setAttribute("id", getId());

      // properties
      m_properties.toXml(doc, stack);

      // for each message range
      for (Iterator it = m_ranges.entrySet().iterator(); it.hasNext(); ) {
        Map.Entry entry = (Map.Entry) it.next();

        Element messages = doc.createElement("messages");
        digest.appendChild(messages);
        messages.setAttribute("period", (String) entry.getKey());

        // for each message
        for (Iterator iMsgs = ((List) entry.getValue()).iterator(); iMsgs.hasNext(); ) {
          DigestMessage msg = (DigestMessage) iMsgs.next();

          Element message = doc.createElement("message");
          messages.appendChild(message);
          Xml.encodeAttribute(message, "subject", msg.getSubject());
          Xml.encodeAttribute(message, "body", msg.getBody());
        }
      }

      stack.pop();

      return digest;
    }