Package com.rometools.rome.feed.rss

Examples of com.rometools.rome.feed.rss.Item


    @Override
    protected List<Item> buildFeedItems(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
      List<Item> items = new ArrayList<Item>();
      for (String name : model.keySet()) {
        Item item = new Item();
        item.setTitle(name);
        Description description = new Description();
        description.setValue((String) model.get(name));
        item.setDescription(description);
        items.add(item);
      }
      return items;
    }
View Full Code Here


    assertEquals("description", result.getDescription());

    List<?> items = result.getItems();
    assertEquals(2, items.size());

    Item item1 = (Item) items.get(0);
    assertEquals("title1", item1.getTitle());

    Item item2 = (Item) items.get(1);
    assertEquals("title2", item2.getTitle());
  }
View Full Code Here

    Channel channel = new Channel("rss_2.0");
    channel.setTitle("title");
    channel.setLink("http://example.com");
    channel.setDescription("description");

    Item item1 = new Item();
    item1.setTitle("title1");

    Item item2 = new Item();
    item2.setTitle("title2");

    List<Item> items = new ArrayList<Item>(2);
    items.add(item1);
    items.add(item2);
    channel.setItems(items);
View Full Code Here

    channel.setDescription("description");

    String encoding = "ISO-8859-1";
    channel.setEncoding(encoding);

    Item item1 = new Item();
    item1.setTitle("title1");

    MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
    converter.write(channel, null, outputMessage);

    assertEquals("Invalid content-type", new MediaType("application", "rss+xml", Charset.forName(encoding)),
View Full Code Here

*/
public class RSS090DescriptionParser extends RSS090Parser {

  @Override
  protected Item parseItem(Element rssRoot, Element eItem, Locale locale) {
    Item item = super.parseItem(rssRoot, eItem, locale);
    Element e = eItem.getChild("description", getRSSNamespace());
    if (e != null) {
      Description desc = new Description();
      desc.setValue(e.getText());
      item.setDescription(desc);
    }

    return item;
  }
View Full Code Here

    }

    @Override
    protected Item createRSSItem(final SyndEntry sEntry) {

        final Item item = super.createRSSItem(sEntry);

        final List<SyndPerson> authors = sEntry.getAuthors();
        if (Lists.isNotEmpty(authors)) {
            final SyndPerson author = authors.get(0);
            item.setAuthor(author.getEmail());
        }

        Guid guid = null;
        final String uri = sEntry.getUri();
        final String link = sEntry.getLink();
        if (uri != null) {
            guid = new Guid();
            guid.setPermaLink(false);
            guid.setValue(uri);
        } else if (link != null) {
            guid = new Guid();
            guid.setPermaLink(true);
            guid.setValue(link);

        }
        item.setGuid(guid);

        final SyndLink comments = sEntry.findRelatedLink("comments");
        if (comments != null && (comments.getType() == null || comments.getType().endsWith("html"))) {
            item.setComments(comments.getHref());
        }
        return item;

    }
View Full Code Here

    }

    @Override
    protected Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) {

        final Item item = super.parseItem(rssRoot, eItem, locale);

        final Element pubDate = eItem.getChild("pubDate", getRSSNamespace());
        if (pubDate != null) {
            item.setPubDate(DateParser.parseDate(pubDate.getText(), locale));
        }

        final Element expirationDate = eItem.getChild("expirationDate", getRSSNamespace());
        if (expirationDate != null) {
            item.setExpirationDate(DateParser.parseDate(expirationDate.getText(), locale));
        }

        final Element description = eItem.getChild("description", getRSSNamespace());
        if (description != null) {
            final String type = description.getAttributeValue("type");
            if (type != null) {
                item.getDescription().setType(type);
            }
        }

        return item;
View Full Code Here

    // synd.description -> rss.description

    @Override
    protected Item createRSSItem(final SyndEntry sEntry) {

        final Item item = super.createRSSItem(sEntry);

        final SyndContent desc = sEntry.getDescription();
        if (desc != null) {
            item.setDescription(createItemDescription(desc));
        }

        final List<SyndContent> contents = sEntry.getContents();
        if (Lists.isNotEmpty(contents)) {
            item.setContent(createItemContent(contents.get(0)));
        }

        final String uri = sEntry.getUri();
        if (uri != null) {
            item.setUri(uri);
        }

        return item;
    }
View Full Code Here

     * @param eItem the item element to parse.
     * @return the parsed RSSItem bean.
     */
    protected Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) {

        final Item item = new Item();

        final Element title = eItem.getChild("title", getRSSNamespace());
        if (title != null) {
            item.setTitle(title.getText());
        }

        final Element link = eItem.getChild("link", getRSSNamespace());
        if (link != null) {
            item.setLink(link.getText());
            item.setUri(link.getText());
        }

        item.setModules(parseItemModules(eItem, locale));

        final List<Element> foreignMarkup = extractForeignMarkup(eItem, item, getRSSNamespace());
        // content:encoded elements are treated special, without a module, they have to be removed
        // from the foreign markup to avoid duplication in case of read/write. Note that this fix
        // will break if a content module is used
        final Iterator<Element> iterator = foreignMarkup.iterator();
        while (iterator.hasNext()) {
            final Element element = iterator.next();
            final Namespace eNamespace = element.getNamespace();
            final String eName = element.getName();
            if (getContentNamespace().equals(eNamespace) && eName.equals("encoded")) {
                iterator.remove();
            }
        }

        if (!foreignMarkup.isEmpty()) {
            item.setForeignMarkup(foreignMarkup);
        }

        return item;
    }
View Full Code Here

        return syndEntry;
    }

    @Override
    protected Item createRSSItem(final SyndEntry sEntry) {
        final Item item = super.createRSSItem(sEntry);
        item.setPubDate(sEntry.getPublishedDate()); // c
        return item;
    }
View Full Code Here

TOP

Related Classes of com.rometools.rome.feed.rss.Item

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.