Java Code Examples for com.rometools.rome.feed.rss.Item#setDescription()
The following examples show how to use
com.rometools.rome.feed.rss.Item#setDescription() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArticleFeedView.java From tutorials with MIT License | 6 votes |
@Override protected List<Item> buildFeedItems(Map<String, Object> map, HttpServletRequest httpStRequest, HttpServletResponse httpStResponse) throws Exception { List list = new ArrayList<Item>(); Item item1 = new Item(); item1.setLink("http://www.baeldung.com/netty-exception-handling"); item1.setTitle("Exceptions in Netty"); Description description1 = new Description(); description1.setValue("In this quick article, we’ll be looking at exception handling in Netty."); item1.setDescription(description1); item1.setPubDate(new Date()); item1.setAuthor("Carlos"); Item item2 = new Item(); item2.setLink("http://www.baeldung.com/cockroachdb-java"); item2.setTitle("Guide to CockroachDB in Java"); Description description2 = new Description(); description2.setValue("This tutorial is an introductory guide to using CockroachDB with Java."); item2.setDescription(description2); item2.setPubDate(new Date()); item2.setAuthor("Baeldung"); list.add(item1); list.add(item2); return list; }
Example 2
Source File: ArticleRssController.java From tutorials with MIT License | 6 votes |
private Channel buildChannel(List<Article> articles){ Channel channel = new Channel("rss_2.0"); channel.setLink("http://localhost:8080/spring-mvc-simple/rss"); channel.setTitle("Article Feed"); channel.setDescription("Article Feed Description"); channel.setPubDate(new Date()); List<Item> items = new ArrayList<>(); for (Article article : articles) { Item item = new Item(); item.setLink(article.getLink()); item.setTitle(article.getTitle()); Description description1 = new Description(); description1.setValue(article.getDescription()); item.setDescription(description1); item.setPubDate(article.getPublishedDate()); item.setAuthor(article.getAuthor()); items.add(item); } channel.setItems(items); return channel; }
Example 3
Source File: ArticleFeedView.java From tutorials with MIT License | 6 votes |
@Override protected List<Item> buildFeedItems(Map<String, Object> map, HttpServletRequest httpStRequest, HttpServletResponse httpStResponse) throws Exception { List list = new ArrayList<Item>(); Item item1 = new Item(); item1.setLink("http://www.baeldung.com/netty-exception-handling"); item1.setTitle("Exceptions in Netty"); Description description1 = new Description(); description1.setValue("In this quick article, we’ll be looking at exception handling in Netty."); item1.setDescription(description1); item1.setPubDate(new Date()); item1.setAuthor("Carlos"); Item item2 = new Item(); item2.setLink("http://www.baeldung.com/cockroachdb-java"); item2.setTitle("Guide to CockroachDB in Java"); Description description2 = new Description(); description2.setValue("This tutorial is an introductory guide to using CockroachDB with Java."); item2.setDescription(description2); item2.setPubDate(new Date()); item2.setAuthor("Baeldung"); list.add(item1); list.add(item2); return list; }
Example 4
Source File: RSS10Parser.java From rome with Apache License 2.0 | 6 votes |
/** * Parses an item element of an RSS document looking for item information. * <p/> * It first invokes super.parseItem and then parses and injects the description property if * present. * <p/> * * @param rssRoot the root element of the RSS document in case it's needed for context. * @param eItem the item element to parse. * @return the parsed RSSItem bean. */ @Override protected Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) { final Item item = super.parseItem(rssRoot, eItem, locale); final Element description = eItem.getChild("description", getRSSNamespace()); if (description != null) { item.setDescription(parseItemDescription(rssRoot, description)); } final Element encoded = eItem.getChild("encoded", getContentNamespace()); if (encoded != null) { final Content content = new Content(); content.setType(Content.HTML); content.setValue(encoded.getText()); item.setContent(content); } final String about = eItem.getAttributeValue("about", getRDFNamespace()); if (about != null) { item.setUri(about); } return item; }
Example 5
Source File: ConverterForRSS091Userland.java From rome with Apache License 2.0 | 6 votes |
@Override protected Item createRSSItem(final SyndEntry sEntry) { final Item item = super.createRSSItem(sEntry); item.setComments(sEntry.getComments()); final SyndContent sContent = sEntry.getDescription(); if (sContent != null) { item.setDescription(createItemDescription(sContent)); } final List<SyndContent> contents = sEntry.getContents(); if (Lists.isNotEmpty(contents)) { final SyndContent syndContent = contents.get(0); final Content cont = new Content(); cont.setValue(syndContent.getValue()); cont.setType(syndContent.getType()); item.setContent(cont); } return item; }
Example 6
Source File: FoundPodcastsRssFeedView.java From podcastpedia-web with MIT License | 6 votes |
protected List buildFeedItems(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { List<Podcast> podcasts = (List<Podcast>) model.get("list_of_podcasts"); List<Item> items = new ArrayList<Item>(podcasts.size()); for (Podcast podcast : podcasts) { Item item = new Item(); // String date = String.format("%1$tY-%1$tm-%1$td", podcast.getLastEpisode().getPublicationDate()); item.setTitle(podcast.getTitle()); item.setPubDate(podcast.getPublicationDate()); item.setLink(model.get("HOST_AND_PORT_URL") + "/podcasts/" + podcast.getPodcastId() + "/" + podcast.getTitleInUrl()); Description podcastDescription = new Description(); podcastDescription.setValue(podcast.getDescription()); item.setDescription(podcastDescription); items.add(item); } return items; }
Example 7
Source File: RssFeedView.java From wallride with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override protected List<Item> buildFeedItems( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { Set<Article> articles = (Set<Article>)model.get("articles"); List<Item> items = new ArrayList<>(articles.size()); for (Article article : articles) { Item item = new Item(); item.setTitle(article.getTitle()); item.setPubDate(Date.from(article.getDate().atZone(ZoneId.systemDefault()).toInstant())); Description description = new Description(); description.setType("text/html"); description.setValue(article.getBody()); item.setDescription(description); item.setLink(link(article)); items.add(item); } return items; }
Example 8
Source File: ConverterForRSS10.java From rome with Apache License 2.0 | 6 votes |
@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; }
Example 9
Source File: RSS090DescriptionParser.java From commafeed with Apache License 2.0 | 5 votes |
@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; }
Example 10
Source File: RssFeedViewTests.java From spring-analysis-note with MIT License | 5 votes |
@Override protected List<Item> buildFeedItems(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { List<Item> items = new ArrayList<>(); 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; }
Example 11
Source File: GenericRssFeedView.java From podcastpedia-web with MIT License | 5 votes |
protected List buildFeedItems(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { List<Podcast> podcasts = (List<Podcast>) model.get("list_of_podcasts"); List<Item> items = new ArrayList<Item>(podcasts.size()); for (Podcast podcast : podcasts) { Episode episode = podcast.getLastEpisode(); Item item = new Item(); String date = String.format("%1$tY-%1$tm-%1$td", episode.getPublicationDate()); item.setTitle(podcast.getTitle()+ " - " + episode.getTitle()); item.setPubDate(podcast.getPublicationDate()); item.setLink( model.get("HOST_AND_PORT_URL") + "/podcasts/" + podcast.getPodcastId() + "/" + podcast.getTitleInUrl() ); Description episodeDescription = new Description(); episodeDescription.setValue(episode.getDescription()); item.setDescription(episodeDescription); //set enclosures List<Enclosure> enclosures = new ArrayList<Enclosure>(); Enclosure enclosure = new Enclosure(); enclosure.setUrl(episode.getMediaUrl()); if(episode.getLength() != null) enclosure.setLength(episode.getLength()); if(episode.getEnclosureType() != null ) enclosure.setType(episode.getEnclosureType()); enclosures.add(enclosure); item.setEnclosures(enclosures); items.add(item); } return items; }
Example 12
Source File: FoundEpisodesRssFeedView.java From podcastpedia-web with MIT License | 5 votes |
protected List buildFeedItems(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { List<Episode> episodes = (List<Episode>) model.get("list_of_episodes"); List<Item> items = new ArrayList<Item>(episodes.size()); for (Episode episode : episodes) { Item item = new Item(); String date = String.format("%1$tY-%1$tm-%1$td", episode.getPublicationDate()); item.setTitle(episode.getTitle()); item.setPubDate(episode.getPublicationDate()); item.setLink(model.get("HOST_AND_PORT_URL") + "/podcasts/" + episode.getPodcastId() + "/" + episode.getPodcast().getTitleInUrl()+ "/episodes/" + episode.getEpisodeId() + "/" + episode.getTitleInUrl()); Description episodeDescription = new Description(); episodeDescription.setValue(episode.getDescription()); item.setDescription(episodeDescription); //set enclosures List<Enclosure> enclosures = new ArrayList<Enclosure>(); Enclosure enclosure = new Enclosure(); enclosure.setUrl(episode.getMediaUrl()); if(episode.getLength() != null) enclosure.setLength(episode.getLength()); if(episode.getEnclosureType() != null ) enclosure.setType(episode.getEnclosureType()); enclosures.add(enclosure); item.setEnclosures(enclosures); items.add(item); } return items; }
Example 13
Source File: HotArticleRssContentView.java From kaif with Apache License 2.0 | 5 votes |
private Item convertArticle(Article article) { Item entry = new Item(); Guid guid = new Guid(); guid.setValue(article.getArticleId().toString()); entry.setGuid(guid); entry.setTitle(cleanXml10Characters(article.getTitle())); entry.setPubDate(Date.from(article.getCreateTime())); Description summary = new Description(); summary.setType("html"); summary.setValue(buildSummary(article)); entry.setDescription(summary); entry.setLink(articleUrl(article)); return entry; }
Example 14
Source File: RssFeedViewTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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; }
Example 15
Source File: RssFeedViewTests.java From java-technology-stack with MIT License | 5 votes |
@Override protected List<Item> buildFeedItems(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { List<Item> items = new ArrayList<>(); 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; }
Example 16
Source File: BasicPodfeedService.java From sakai with Educational Community License v2.0 | 4 votes |
/** * This add a particular podcast to the feed. * * @param title * The title for this podcast * @param mp3link * The URL where the podcast is stored * @param date * The publish date for this podcast * @param blogContent * The description of this podcast * @param cat * The category of entry this is (Podcast) * @param author * The author of this podcast * * @return * A SyndEntryImpl for this podcast */ private Item addPodcast(Map values) { final Item item = new Item(); // set title for this podcast item.setTitle((String) values.get("title")); // Replace all occurrences of pattern (ie, spaces) in input // with hex equivalent (%20) Pattern pattern = Pattern.compile(" "); String url = (String) values.get("url"); Matcher matcher = pattern.matcher(url); url = matcher.replaceAll("%20"); item.setLink(url); // Set Publish date for this podcast/episode // NOTE: date has local time, but when feed rendered, // converts it to GMT item.setPubDate((Date) values.get("date")); // Set description for this podcast/episode final Description itemDescription = new Description(); itemDescription.setType(DESCRIPTION_CONTENT_TYPE); itemDescription.setValue((String) values.get("description")); item.setDescription(itemDescription); // Set guid for this podcast/episode item.setGuid(new Guid()); item.getGuid().setValue((String) values.get("guid")); item.getGuid().setPermaLink(false); // This creates the enclosure so podcatchers (iTunes) can // find the podcasts List enclosures = new ArrayList(); final Enclosure enc = new Enclosure(); enc.setUrl(url); enc.setType((String) values.get("type")); enc.setLength((Long) values.get("len")); enclosures.add(enc); item.setEnclosures(enclosures); // Currently uses 2 modules: // iTunes for podcasting // DCmodule since validators want email with author tag, // so use dc:creator instead List modules = new ArrayList(); // Generate the iTunes tags final EntryInformation iTunesModule = new EntryInformationImpl(); iTunesModule.setAuthor(getMessageBundleString(FEED_ITEM_AUTHOR_STRING)); iTunesModule.setSummary((String) values.get("description")); // Set dc:creator tag final DCModuleImpl dcModule = new DCModuleImpl(); dcModule.setCreator((String) values.get("author")); modules.add(iTunesModule); modules.add(dcModule); item.setModules(modules); return item; }
Example 17
Source File: BasicPodfeedService.java From sakai with Educational Community License v2.0 | 4 votes |
/** * This add a particular podcast to the feed. * * @param title * The title for this podcast * @param mp3link * The URL where the podcast is stored * @param date * The publish date for this podcast * @param blogContent * The description of this podcast * @param cat * The category of entry this is (Podcast) * @param author * The author of this podcast * * @return * A SyndEntryImpl for this podcast */ private Item addPodcast(Map values) { final Item item = new Item(); // set title for this podcast item.setTitle((String) values.get("title")); // Replace all occurrences of pattern (ie, spaces) in input // with hex equivalent (%20) Pattern pattern = Pattern.compile(" "); String url = (String) values.get("url"); Matcher matcher = pattern.matcher(url); url = matcher.replaceAll("%20"); item.setLink(url); // Set Publish date for this podcast/episode // NOTE: date has local time, but when feed rendered, // converts it to GMT item.setPubDate((Date) values.get("date")); // Set description for this podcast/episode final Description itemDescription = new Description(); itemDescription.setType(DESCRIPTION_CONTENT_TYPE); itemDescription.setValue((String) values.get("description")); item.setDescription(itemDescription); // Set guid for this podcast/episode item.setGuid(new Guid()); item.getGuid().setValue((String) values.get("guid")); item.getGuid().setPermaLink(false); // This creates the enclosure so podcatchers (iTunes) can // find the podcasts List enclosures = new ArrayList(); final Enclosure enc = new Enclosure(); enc.setUrl(url); enc.setType((String) values.get("type")); enc.setLength((Long) values.get("len")); enclosures.add(enc); item.setEnclosures(enclosures); // Currently uses 2 modules: // iTunes for podcasting // DCmodule since validators want email with author tag, // so use dc:creator instead List modules = new ArrayList(); // Generate the iTunes tags final EntryInformation iTunesModule = new EntryInformationImpl(); iTunesModule.setAuthor(getMessageBundleString(FEED_ITEM_AUTHOR_STRING)); iTunesModule.setSummary((String) values.get("description")); // Set dc:creator tag final DCModuleImpl dcModule = new DCModuleImpl(); dcModule.setCreator((String) values.get("author")); modules.add(iTunesModule); modules.add(dcModule); item.setModules(modules); return item; }