All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.primefaces.component.feedreader.FeedInput Maven / Gradle / Ivy

There is a newer version: 14.0.0-RC3
Show newest version
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.primefaces.component.feedreader;

import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

public class FeedInput {
      
    public List parse(String url, int size) throws Exception {
        List entries = new ArrayList();
        URL feedSource = new URL(url);
        SyndFeedInput input = new SyndFeedInput();
        SyndFeed feed = input.build(new XmlReader(feedSource));
        int i = 0;
        
        for(Object f : feed.getEntries()) {
            if(i == size)
                break;

            entries.add(f);
            i++;
        }
        
        return entries;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy