Package org.primefaces.component.feedreader

Source Code of org.primefaces.component.feedreader.FeedInput

/*
* 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;
    }
}
TOP

Related Classes of org.primefaces.component.feedreader.FeedInput

TOP
Copyright © 2018 www.massapi.com. 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.