Package com.sun.syndication.feed.atom

Examples of com.sun.syndication.feed.atom.Content


       
        // Create a new Feed
        Feed feed = new Feed();
        feed.setId("accounts");
        feed.setTitle("Account Report Feed");
        Content subtitle = new Content();
        subtitle.setValue("This is a sample feed");
        feed.setSubtitle(subtitle);
        Link link = new Link();
        link.setHref("http://incubator.apache.org/tuscany");
        feed.getAlternateLinks().add(link);
View Full Code Here


        String value = Double.toString(balance);
       
        Entry entry = new Entry();
        entry.setId("account-" + id);
        entry.setTitle("Account Report Entry");
        Content summary = new Content();
        summary.setType(Content.HTML);
        summary.setValue("This is your account report: <b>" + value + "</b>");
        entry.setSummary(summary);
        Content content = new Content();
        content.setValue(value);
        entry.setContents(Collections.singletonList(content));
        return entry;
    }
View Full Code Here

    final List<Entry> entries = Lists.newArrayList();

    for (final Message msg : messages) {
      final Entry e = new Entry();
      final Content c = new Content();

      c.setType("text/html");
      c.setValue(msg.getHtml());

      e.setId(Hash.md5(msg.getSubject()).toHex());
      e.setUpdated(new Date()); // TODO updated date? not easy ...
      e.setTitle(msg.getSubject());
      e.setContents(Arrays.asList(c));
View Full Code Here

            feedEntry.setId(key.toString());
            feedEntry.setTitle(item.getTitle());
   
            String value = item.getContents();
            if (value != null) {
                Content content = new Content();
                content.setType("text/xml");
                content.setValue(value);
                List<Content> contents = new ArrayList<Content>();
                contents.add(content);
                feedEntry.setContents(contents);
            }
   
            String href = item.getLink();
            if (href == null) {
                href = key.toString();
            }
            Link link = new Link();
            link.setRel("edit");
            link.setHref(href);
            feedEntry.getOtherLinks().add(link);
            link = new Link();
            link.setRel("alternate");
            link.setHref(href);
            feedEntry.getAlternateLinks().add(link);
   
            Date date = item.getDate();
            if (date == null) {
                date = new Date();
            }
            feedEntry.setCreated(date);
            return feedEntry;
           
        } else if (data != null) {
            Entry feedEntry = new Entry();
            feedEntry.setId(key.toString());
            feedEntry.setTitle("item");
   
            // Convert the item to XML
            String value = mediator.mediate(data, itemClassType, itemXMLType, null).toString();
           
            Content content = new Content();
            content.setType("text/xml");
            content.setValue(value);
            List<Content> contents = new ArrayList<Content>();
            contents.add(content);
            feedEntry.setContents(contents);
   
            Link link = new Link();
View Full Code Here

                Item item = new Item();
                item.setTitle(feedEntry.getTitle());
               
                List<?> contents = feedEntry.getContents();
                if (!contents.isEmpty()) {
                    Content content = (Content)contents.get(0);
                    String value = content.getValue();
                    item.setContents(value);
                }
               
                for (Object l : feedEntry.getOtherLinks()) {
                    Link link = (Link)l;
                    if (link.getRel() == null || "edit".equals(link.getRel())) {
                        String href = link.getHref();
                        if (href.startsWith("null/")) {
                            href = href.substring(5);
                        }
                        item.setLink(href);
                        break;
                    }
                }
               
                item.setDate(feedEntry.getCreated());
               
                return new org.apache.tuscany.sca.data.collection.Entry<Object, Object>(key, item);
               
            } else {
                String key = feedEntry.getId();
               
                // Create the item from XML
                List<?> contents = feedEntry.getContents();
                if (contents.isEmpty()) {
                    return null;
                }
                Content content = (Content)contents.get(0);
                String value = content.getValue();
                Object data = mediator.mediate(value, itemXMLType, itemClassType, null);

                return new org.apache.tuscany.sca.data.collection.Entry<Object, Object>(key, data);
            }
        } else {
View Full Code Here

       
        // Create a new Feed
        Feed feed = new Feed();
        feed.setId("accounts");
        feed.setTitle("Account Report Feed");
        Content subtitle = new Content();
        subtitle.setValue("This is a sample feed");
        feed.setSubtitle(subtitle);
        Link link = new Link();
        link.setHref("http://incubator.apache.org/tuscany");
        feed.getAlternateLinks().add(link);
View Full Code Here

        String value = Double.toString(balance);
       
        Entry entry = new Entry();
        entry.setId("account-" + id);
        entry.setTitle("Account Report Entry");
        Content summary = new Content();
        summary.setType(Content.HTML);
        summary.setValue("This is your account report: <b>" + value + "</b>");
        entry.setSummary(summary);
        Content content = new Content();
        content.setValue(value);
        entry.setContents(Collections.singletonList(content));
        return entry;
    }
View Full Code Here

   
            // Convert the item to XML
            String value = mediator.mediate(item, itemClassType, itemXMLType, null).toString();
            value = value.substring(value.indexOf('>') +1);
           
            Content content = new Content();
            content.setType("text/xml");
            content.setValue(value);
            List<Content> contents = new ArrayList<Content>();
            contents.add(content);
            entry.setContents(contents);
   
            Link link = new Link();
View Full Code Here

        if (entry != null) {
            List<?> contents = entry.getContents();
            if (contents.isEmpty()) {
                return null;
            }
            Content content = (Content)contents.get(0);
   
            // Create the item from XML
            String value = content.getValue();
            Object item = mediator.mediate(value, itemXMLType, itemClassType, null);

            return item;
        } else {
            return null;
View Full Code Here

        document.getRootElement().addContent(root);
        WireFeedInput input = new WireFeedInput();
        feed = (Feed)input.build(document);
        Entry entry = (Entry)feed.getEntries().get(0);
        if (entry.getContents().size() != 0) {
            Content content = (Content)entry.getContents().get(0);
            if ("text/xml".equals(content.getType())) {
                Element element = root.getChild("content", root.getNamespace());
                if (!element.getChildren().isEmpty()) {
                    element = (Element)element.getChildren().get(0);
                    XMLOutputter outputter = new XMLOutputter();
                    StringWriter sw = new StringWriter();
                    outputter.output(element, sw);
                    content.setValue(sw.toString());
                }
            }
        }
        return entry;
    }
View Full Code Here

TOP

Related Classes of com.sun.syndication.feed.atom.Content

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.