/** * Accepts only release announce. */ public boolean isRelease(@Body SyndFeed feed) { SyndEntry firstEntry = (SyndEntry) feed.getEntries().get(0); return firstEntry.getTitle().toLowerCase().contains("release"); }
for (SyndEntry entry : (List<SyndEntry>) feed.getEntries()) {
@SuppressWarnings( "unchecked" ) public static void sortSyndEntryOrderByPublishedDate( SyndFeed feed ) { Collections.sort( feed.getEntries(), new Comparator<SyndEntry>() { public int compare( SyndEntry o1, SyndEntry o2 ) { Date d1 = ( (SyndEntry) o1 ).getPublishedDate(); Date d2 = ( (SyndEntry) o2 ).getPublishedDate(); // sort desc by date if ( d2 != null && d1 != null ) return d2.compareTo( d1 ); return -1; } } ); }
@Override public void parse(SyndFeed feed) throws Exception { @SuppressWarnings("unchecked") List<SyndEntry> entries = feed.getEntries(); Iterator<SyndEntry> itEntries = entries.iterator(); while (itEntries.hasNext()) { SyndEntry entry = (SyndEntry) itEntries.next(); LOGGER.info("Title: " + entry.getTitle()); } }
/** * <p>Combine the entries in two feeds into a single feed.</p> * * <p>The returned feed will have the same data as the newFeed parameter, with * the entries from originalFeed appended to the end of its entries.</p> * * @param originalFeed * @param newFeed * @return */ public static SyndFeed combineFeeds(SyndFeed originalFeed, SyndFeed newFeed) { SyndFeed result; try { result = (SyndFeed) newFeed.clone(); result.getEntries().addAll(result.getEntries().size(), originalFeed.getEntries()); return result; } catch (CloneNotSupportedException e) { IllegalArgumentException iae = new IllegalArgumentException("Cannot clone feed"); iae.initCause(e); throw iae; } }
/** * <p>Combine the entries in two feeds into a single feed.</p> * * <p>The returned feed will have the same data as the newFeed parameter, with * the entries from originalFeed appended to the end of its entries.</p> * * @param originalFeed * @param newFeed * @return */ public static SyndFeed combineFeeds(SyndFeed originalFeed, SyndFeed newFeed) { SyndFeed result; try { result = (SyndFeed) newFeed.clone(); result.getEntries().addAll(result.getEntries().size(), originalFeed.getEntries()); return result; } catch (CloneNotSupportedException e) { IllegalArgumentException iae = new IllegalArgumentException("Cannot clone feed"); iae.initCause(e); throw iae; } }
/** * Render as many of the given <code>Channel</code>'s items as needed, * according to the value of the optional <code>count</code> parameter * and the number of items in the feed. * @param writer the output writer * @param paramObj our parameter helper object * @throws java.io.IOException */ private void renderEntries(SyndFeed feed, Writer writer, RSSMacroParameters paramObj) throws java.io.IOException { List listEntries = feed.getEntries(); int max = paramObj.evalCount(listEntries.size()); for (int i = 0; i < max; i++) { renderEntry((SyndEntry)listEntries.get(i), writer, paramObj); } }
SyndFeedInput fr = new SyndFeedInput(); SyndFeed sf = fr.build(new XmlReader(myInputStream)); List<?> entries = sf.getEntries();
@SuppressWarnings("unchecked") private Pair<SyndFeed, List<SyndEntry>> feedPair(RufusFeed request) { SyndFeed feed = request.getFeed(); return ImmutablePair.of(feed, feed.getEntries()); }
URL feedUrl = new URL("http://www.bloomberg.com/tvradio/podcast/cat_markets.xml"); SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(feedUrl)); for (Iterator i = feed.getEntries().iterator(); i.hasNext();) { SyndEntry entry = (SyndEntry) i.next(); System.out.println("title |"+entry.getTitle()+" " -timeStamp "+entry.getPublishedDate()"\n") }
URL url = new URL("http://feeds.feedburner.com/javatipsfeed"); XmlReader reader = null; try { reader = new XmlReader(url); SyndFeed feeder = new SyndFeedInput().build(reader); System.out.println("Feed Title: "+ feeder.getAuthor()); for (Iterator i = feeder.getEntries().iterator(); i.hasNext();) { SyndEntry syndEntry = (SyndEntry) i.next(); System.out.println(syndEntry.getTitle()); } } finally { if (reader != null) reader.close(); }
public static List<Dataset> getDatasetsForFeed(Dataset datasetOrig) throws StudyImporterException { SyndFeedInput input = new SyndFeedInput(); SyndFeed feed; String rss = getRss(datasetOrig); try { feed = input.build(new XmlReader(new URL(rss))); } catch (FeedException | IOException e) { throw new StudyImporterException("failed to read rss feed [" + rss + "]", e); } List<Dataset> datasets = new ArrayList<>(); final List entries = feed.getEntries(); for (Object entry : entries) { if (entry instanceof SyndEntry) { datasets.add(datasetFor(datasetOrig, (SyndEntry) entry)); } } return datasets; }
public static void main(String[] args) throws Exception { ClientResource mailClient = new ClientResource( "http://localhost:8111/accounts/chunkylover53/feeds/xyz"); // Display the retrieved Atom feed and entries Feed atomFeed = mailClient.get(Feed.class); System.out.println("\nAtom feed: " + atomFeed.getTitle() + "\n"); for (Entry entry : atomFeed.getEntries()) { System.out.println("Title : " + entry.getTitle()); System.out.println("Summary: " + entry.getSummary()); } // Display the retrieved RSS feed and entries SyndFeed rssFeed = mailClient.get(SyndFeed.class); System.out.println("\nRSS feed: " + rssFeed.getTitle() + "\n"); @SuppressWarnings("unchecked") List<SyndEntry> entries = (List<SyndEntry>) rssFeed.getEntries(); for (SyndEntry entry : entries) { System.out.println("Title : " + entry.getTitle()); System.out.println("Summary: " + entry.getDescription().getValue()); } } }
public void run ( ) { while ( isActive( ) ) { try { Thread.sleep( rate ); rss_input = new SyndFeedInput(); feed = rss_input.build(new XmlReader(url)); for (SyndEntry entry: (List<SyndEntry>) feed.getEntries()) { String title = entry.getTitle(); String link = entry.getLink(); String description= entry.getDescription().getValue(); String author = entry.getAuthor(); long publish_date = entry.getPublishedDate().getTime(); postStreamElement(publish_date,new Serializable[] {title,author,description,link}); } }catch (com.sun.syndication.io.FeedException e){ logger.error( e.getMessage( ) , e ); }catch ( InterruptedException e ) { logger.error( e.getMessage( ) , e ); }catch (IOException e) { logger.error( e.getMessage( ) , e ); } } }
/** This method will take a SyndFeed object with a SimpleListExtension on it and populate the entries * with current SleEntry values for sorting and grouping. * <b>NB</b>: This basically does this by re-generating the XML for all the entries then re-parsing them * into the SLE data structures. It is a very heavy operation and should not be called frequently! */ public static void initializeForSorting( SyndFeed feed )throws FeedException { List syndEntries = feed.getEntries(); // TODO: the null parameter below will break delegating parsers and generators ModuleGenerators g = new ModuleGenerators( feed.getFeedType() + ITEM_MODULE_GENERATORS_POSFIX_KEY, null); SyndFeedOutput o = new SyndFeedOutput(); Document d = o.outputJDom( feed ); SyndFeed feed2 = new SyndFeedInput().build( d ); feed.copyFrom( feed2 ); }
private void buildListHTML(HtmlBuffer buf, SyndFeed feed){ List entries = feed.getEntries(); if(entries != null){ buf.appendStartTag("dl"); for(Iterator i = entries.iterator();i.hasNext();){ SyndEntry entry = (SyndEntry) i.next(); buf.appendStartTag("dt"); buf.setNewline(false); buf.appendAnchor(entry.getLink(),entry.getTitle()); if(entry.getPublishedDate() != null) buf.appendBody(HtmlBuffer.ENTITY_SPACE + CmsConstants.DATEFORMAT.format(entry.getPublishedDate())); buf.setNewline(true); buf.endTag(); buf.appendStartTag("dd"); buf.appendBody(entry.getDescription().getValue()); buf.endTag(); //tr } buf.endTag(); } }
/** This method will take a SyndFeed object with a SimpleListExtension on it and populate the entries * with current SleEntry values for sorting and grouping. * <b>NB</b>: This basically does this by re-generating the XML for all the entries then re-parsing them * into the SLE data structures. It is a very heavy operation and should not be called frequently! */ public static void initializeForSorting( SyndFeed feed )throws FeedException { List syndEntries = feed.getEntries(); // TODO: the null parameter below will break delegating parsers and generators ModuleGenerators g = new ModuleGenerators( feed.getFeedType() + ITEM_MODULE_GENERATORS_POSFIX_KEY, null); SyndFeedOutput o = new SyndFeedOutput(); Document d = o.outputJDom( feed ); SyndFeed feed2 = new SyndFeedInput().build( d ); feed.copyFrom( feed2 ); }
/** This method will take a SyndFeed object with a SimpleListExtension on it and populate the entries * with current SleEntry values for sorting and grouping. * <b>NB</b>: This basically does this by re-generating the XML for all the entries then re-parsing them * into the SLE data structures. It is a very heavy operation and should not be called frequently! */ public static void initializeForSorting( SyndFeed feed )throws FeedException { List syndEntries = feed.getEntries(); // TODO: the null parameter below will break delegating parsers and generators ModuleGenerators g = new ModuleGenerators( feed.getFeedType() + ITEM_MODULE_GENERATORS_POSFIX_KEY, null); SyndFeedOutput o = new SyndFeedOutput(); Document d = o.outputJDom( feed ); SyndFeed feed2 = new SyndFeedInput().build( d ); feed.copyFrom( feed2 ); }
/** This method will take a SyndFeed object with a SimpleListExtension on it and populate the entries * with current SleEntry values for sorting and grouping. * <b>NB</b>: This basically does this by re-generating the XML for all the entries then re-parsing them * into the SLE data structures. It is a very heavy operation and should not be called frequently! */ public static void initializeForSorting( SyndFeed feed )throws FeedException { List syndEntries = feed.getEntries(); // TODO: the null parameter below will break delegating parsers and generators ModuleGenerators g = new ModuleGenerators( feed.getFeedType() + ITEM_MODULE_GENERATORS_POSFIX_KEY, null); SyndFeedOutput o = new SyndFeedOutput(); Document d = o.outputJDom( feed ); SyndFeed feed2 = new SyndFeedInput().build( d ); feed.copyFrom( feed2 ); }
private static void _regexpStrip(SyndFeed syndFeed) { syndFeed.setTitle(_regexpStrip(syndFeed.getTitle())); syndFeed.setDescription(_regexpStrip(syndFeed.getDescription())); List<SyndEntry> syndEntries = syndFeed.getEntries(); for (SyndEntry syndEntry : syndEntries) { syndEntry.setTitle(_regexpStrip(syndEntry.getTitle())); SyndContent syndContent = syndEntry.getDescription(); syndContent.setValue(_regexpStrip(syndContent.getValue())); } }