Java Code Examples for com.rometools.rome.feed.synd.SyndEntry#getTitle()
The following examples show how to use
com.rometools.rome.feed.synd.SyndEntry#getTitle() .
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: Utilities.java From SimpleNews with Apache License 2.0 | 5 votes |
static Entry getEntryFromRSSItem(SyndEntry item, Long feedId, String source, long categoryId) { if (item != null) { if (item.getTitle() == null) { return null; } Object url = item.getLink(); if (url == null) { return null; } Date pubDate = item.getPublishedDate(); Long time = null; if (pubDate != null) { time = pubDate.getTime(); } SyndContent desc = item.getDescription(); String description = null; if (desc != null && desc.getValue() != null) { description = desc.getValue(); description = description.replaceAll("<.*?>", "").replace("()", "").replace(" ", "").trim(); } return new Entry(null, feedId, categoryId, item.getTitle().trim(), description, time, source, url.toString(), null, null, null, null, false); } return null; }
Example 2
Source File: FeedParser.java From commafeed with Apache License 2.0 | 5 votes |
private String getTitle(SyndEntry item) { String title = item.getTitle(); if (StringUtils.isBlank(title)) { Date date = item.getPublishedDate(); if (date != null) { title = DateFormat.getInstance().format(date); } else { title = "(no title)"; } } return StringUtils.trimToNull(title); }
Example 3
Source File: SyndFeedTest.java From rome with Apache License 2.0 | 4 votes |
public String getEntryTitle(final Object o) throws Exception { final SyndEntry e = (SyndEntry) o; return e.getTitle(); }
Example 4
Source File: FeedParserBolt.java From storm-crawler with Apache License 2.0 | 4 votes |
private List<Outlink> parseFeed(String url, byte[] content, Metadata parentMetadata) throws Exception { List<Outlink> links = new ArrayList<>(); SyndFeed feed = null; try (ByteArrayInputStream is = new ByteArrayInputStream(content)) { SyndFeedInput input = new SyndFeedInput(); feed = input.build(new InputSource(is)); } URL sURL = new URL(url); List<SyndEntry> entries = feed.getEntries(); for (SyndEntry entry : entries) { String targetURL = entry.getLink(); // targetURL can be null?!? // e.g. feed does not use links but guid if (StringUtils.isBlank(targetURL)) { targetURL = entry.getUri(); if (StringUtils.isBlank(targetURL)) { continue; } } Outlink newLink = filterOutlink(sURL, targetURL, parentMetadata); if (newLink == null) continue; String title = entry.getTitle(); if (StringUtils.isNotBlank(title)) { newLink.getMetadata().setValue("feed.title", title.trim()); } Date publishedDate = entry.getPublishedDate(); if (publishedDate != null) { // filter based on the published date if (filterHoursSincePub != -1) { Calendar rightNow = Calendar.getInstance(); rightNow.add(Calendar.HOUR, -filterHoursSincePub); if (publishedDate.before(rightNow.getTime())) { LOG.info( "{} has a published date {} which is more than {} hours old", targetURL, publishedDate.toString(), filterHoursSincePub); continue; } } newLink.getMetadata().setValue("feed.publishedDate", publishedDate.toString()); } SyndContent description = entry.getDescription(); if (description != null && StringUtils.isNotBlank(description.getValue())) { newLink.getMetadata().setValue("feed.description", description.getValue()); } links.add(newLink); } return links; }