当前位置: 首页>>代码示例>>Java>>正文


Java SyndFeed.getEntries方法代码示例

本文整理汇总了Java中com.rometools.rome.feed.synd.SyndFeed.getEntries方法的典型用法代码示例。如果您正苦于以下问题:Java SyndFeed.getEntries方法的具体用法?Java SyndFeed.getEntries怎么用?Java SyndFeed.getEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.rometools.rome.feed.synd.SyndFeed的用法示例。


在下文中一共展示了SyndFeed.getEntries方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: importPublications

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
public void importPublications(String projectID) throws Exception {
    LOGGER.info("Getting new publications from {} RSS feed...", sourceSystemID);
    SyndFeed feed = retrieveFeed();

    List<MCRObject> importedObjects = new ArrayList<>();
    for (SyndEntry entry : feed.getEntries()) {
        MCRObject importedObject = handleFeedEntry(entry, projectID);
        if (importedObject != null) {
            importedObjects.add(importedObject);
        }
    }

    int numPublicationsImported = importedObjects.size();
    LOGGER.info("imported {} publications.", numPublicationsImported);

    if ((numPublicationsImported > 0) && (xsl2BuildNotificationMail != null)) {
        sendNotificationMail(importedObjects);
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:20,代码来源:MCRRSSFeedImporter.java

示例2: run

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
@Scheduled(fixedRate=DateTimeConstants.MILLIS_PER_DAY)
public void run() {
    LocalDateTime lastImport = service.getLastImportDate(PublicationSource.ARXIV);
    for (String feedKey : FEEDS) {
        SyndFeedInput input = new SyndFeedInput();
        try {
            SyndFeed feed = input.build(new XmlReader(new URL(ROOT_RSS_URL + feedKey)));
            List<String> ids = new ArrayList<String>(feed.getEntries().size());
            for (SyndEntry entry : feed.getEntries()) {
                ids.add(entry.getLink().replace(URI_PREFIX, ""));
            }
            
            URL url = new URL("http://export.arxiv.org/api/query?id_list=" + joiner.join(ids) + "&max_results=100");
            try (InputStream inputStream = url.openStream()) {
                List<Publication> publications = extractPublications(inputStream, lastImport, ids.size());
                publications = publications.stream().filter(p -> p.getCreated().isAfter(lastImport)).collect(Collectors.toList());
                logger.info("Obtained publications from arxiv for category {}: {}", feedKey, publications.size());
                service.storePublication(publications);
            }
            
        } catch (IllegalArgumentException | FeedException | IOException e) {
            logger.error("Problem getting arxiv RSS feed", e);
        }
    }
}
 
开发者ID:Glamdring,项目名称:scientific-publishing,代码行数:26,代码来源:ArxivImporter.java

示例3: getLatestEntry

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
/**
 * Returns the most recent entry or null, if no entries are found.
 */
private SyndEntry getLatestEntry(SyndFeed feed) {
    List<SyndEntry> allEntries = feed.getEntries();
    SyndEntry lastEntry = null;
    if (allEntries.size() >= 1) {
        /*
         * The entries are stored in the SyndFeed object in the following order -
         * the newest entry has index 0. The order is determined from the time the entry was posted, not the
         * published time of the entry.
         */
        lastEntry = allEntries.get(0);
    } else {
        logger.debug("No entries found");
    }
    return lastEntry;
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:19,代码来源:FeedHandler.java

示例4: testGenerate

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
/**
 * Test of generate method, of class com.rometools.rome.feed.module.photocast.io.Generator.
 */
public void testGenerate() throws Exception {
    final SyndFeedInput input = new SyndFeedInput();

    final SyndFeed feed = input.build(new File(super.getTestFile("index.rss")));
    final List<SyndEntry> entries = feed.getEntries();
    for (int i = 0; i < entries.size(); i++) {
        LOG.debug("{}", entries.get(i).getModule(PhotocastModule.URI));
    }
    final SyndFeedOutput output = new SyndFeedOutput();
    output.output(feed, new File("target/index.rss"));
    final SyndFeed feed2 = input.build(new File("target/index.rss"));
    final List<SyndEntry> entries2 = feed2.getEntries();
    for (int i = 0; i < entries.size(); i++) {
        assertEquals("Module test", entries.get(i).getModule(PhotocastModule.URI), entries2.get(i).getModule(PhotocastModule.URI));
    }
}
 
开发者ID:rometools,项目名称:rome-modules,代码行数:20,代码来源:GeneratorTest.java

示例5: getSyndFeed

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
/**
 * Gets a filtered version of the SyndFeed that only has entries that were changed in the last
 * setSyndFeed() call.
 *
 * @return
 */
@Override
public synchronized SyndFeed getSyndFeed() {
    try {
        final SyndFeed feed = (SyndFeed) super.getSyndFeed().clone();

        final List<SyndEntry> changedEntries = new ArrayList<SyndEntry>();

        final List<SyndEntry> entries = feed.getEntries();
        for (final SyndEntry entry : entries) {
            if (changedMap.containsKey(entry.getUri())) {
                changedEntries.add(entry);
            }
        }

        feed.setEntries(changedEntries);

        return feed;
    } catch (final CloneNotSupportedException ex) {
        throw new RuntimeException(ex);
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:28,代码来源:DeltaSyndFeedInfo.java

示例6: testGenerate

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
public void testGenerate() throws Exception {
    final SyndFeedInput input = new SyndFeedInput();

    final SyndFeed feed = input.build(new File(super.getTestFile("xml/custom-tags-example.xml")));
    final SyndFeedOutput output = new SyndFeedOutput();
    output.output(feed, new File("target/custom-tags-example.xml"));
    final SyndFeed feed2 = input.build(new File("target/custom-tags-example.xml"));

    final List<SyndEntry> entries = feed.getEntries();
    final SyndEntry entry = entries.get(0);
    final CustomTags customTags = (CustomTags) entry.getModule(CustomTags.URI);

    final List<SyndEntry> entries2 = feed2.getEntries();
    final SyndEntry entry2 = entries2.get(0);
    final CustomTags customTags2 = (CustomTags) entry2.getModule(CustomTags.URI);

    final Iterator<CustomTag> it = customTags.getValues().iterator();
    final Iterator<CustomTag> it2 = customTags2.getValues().iterator();
    while (it.hasNext()) {
        final CustomTag tag = it.next();
        final CustomTag tag2 = it2.next();
        LOG.debug("tag1: {}", tag);
        LOG.debug("tag2: {}", tag2);
        Assert.assertEquals(tag, tag2);
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:27,代码来源:CustomTagGeneratorTest.java

示例7: setSyndFeed

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
/**
 * Overrides super class method to update changedMap and entryTagsMap for tracking changed
 * entries.
 *
 * @param feed
 */
@Override
public final synchronized void setSyndFeed(final SyndFeed feed) {
    super.setSyndFeed(feed);

    changedMap.clear();
    final List<SyndEntry> entries = feed.getEntries();
    for (final SyndEntry entry : entries) {
        final String currentEntryTag = computeEntryTag(entry);
        final String previousEntryTag = entryTagsMap.get(entry.getUri());

        if (previousEntryTag == null || !currentEntryTag.equals(previousEntryTag)) {
            // Entry has changed
            changedMap.put(entry.getUri(), Boolean.TRUE);
        }
        entryTagsMap.put(entry.getUri(), currentEntryTag);
    }
}
 
开发者ID:rometools,项目名称:rome-certiorem,代码行数:24,代码来源:DeltaSyndFeedInfo.java

示例8: atestParse

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
public void atestParse() throws Exception {

        final SyndFeedInput input = new SyndFeedInput();
        final File testDir = new File(super.getTestFile("test/xml"));
        final File[] testFiles = testDir.listFiles();
        for (int h = 0; h < testFiles.length; h++) {
            if (!testFiles[h].getName().endsWith(".xml")) {
                continue;
            }
            LOG.debug(testFiles[h].getName());
            final SyndFeed feed = input.build(testFiles[h]);
            final List<SyndEntry> entries = feed.getEntries();
            final CreativeCommons fMod = (CreativeCommons) feed.getModule(CreativeCommons.URI);
            LOG.debug("{}", fMod);
            for (int i = 0; i < entries.size(); i++) {
                final SyndEntry entry = entries.get(i);
                final CreativeCommons eMod = (CreativeCommons) entry.getModule(CreativeCommons.URI);
                LOG.debug("\nEntry:");
                LOG.debug("{}", eMod);
            }
        }
    }
 
开发者ID:rometools,项目名称:rome-modules,代码行数:23,代码来源:ModuleParserTest.java

示例9: testResearch2Parse

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
/**
 * Test of parse method, of class com.totsp.xml.syndication.base.io.GoogleBaseParser.
 */
public void testResearch2Parse() throws Exception {
    LOG.debug("testResearch2Parse");
    final SyndFeedInput input = new SyndFeedInput();
    final Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(0);
    final SyndFeed feed = input.build(new File(super.getTestFile("xml/research2.xml")));
    final List<SyndEntry> entries = feed.getEntries();
    final SyndEntry entry = entries.get(0);
    final ScholarlyArticle module = (ScholarlyArticle) entry.getModule(GoogleBase.URI);
    Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
    cal.set(2005, 11, 20, 0, 0, 0);
    Assert.assertEquals("Expiration Date", cal.getTime(), module.getExpirationDate());
    this.assertEquals("Labels", new String[] { "Economy", "Tsunami" }, module.getLabels());
    cal.set(2005, 1, 25);
    Assert.assertEquals("PubDate", cal.getTime(), module.getPublishDate());
    this.assertEquals("Authors", new String[] { "James Smith" }, module.getAuthors());
    Assert.assertEquals("Pub Name", "Tsunami and the Economy", module.getPublicationName());
    Assert.assertEquals("Pub Vol", "III", module.getPublicationVolume());
    Assert.assertEquals("Pages", new Integer(5), module.getPages());
}
 
开发者ID:rometools,项目名称:rome,代码行数:24,代码来源:GoogleBaseParserTest.java

示例10: testReview2Parse

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
/**
 * Test of parse method, of class com.totsp.xml.syndication.base.io.GoogleBaseParser.
 */
public void testReview2Parse() throws Exception {
    LOG.debug("testReview2Parse");
    final SyndFeedInput input = new SyndFeedInput();
    final Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(0);
    final SyndFeed feed = input.build(new File(super.getTestFile("xml/reviews2.xml")));
    final List<SyndEntry> entries = feed.getEntries();
    final SyndEntry entry = entries.get(0);
    final Review module = (Review) entry.getModule(GoogleBase.URI);
    Assert.assertEquals("Image Link", "http://www.providers-website.com/image1.jpg", module.getImageLinks()[0].toString());
    cal.set(2005, 11, 20, 0, 0, 0);
    Assert.assertEquals("Expiration Date", cal.getTime(), module.getExpirationDate());
    this.assertEquals("Labels", new String[] { "Review", "Earth", "Google" }, module.getLabels());
    cal.set(2005, 2, 24);
    Assert.assertEquals("PubDate", cal.getTime(), module.getPublishDate());
    this.assertEquals("Authors", new String[] { "Jimmy Smith" }, module.getAuthors());
    Assert.assertEquals("Name of Item Rev", "Google Earth", module.getNameOfItemBeingReviewed());
    Assert.assertEquals("Type", "Product", module.getReviewType());
    Assert.assertEquals("Rever Type", "editorial", module.getReviewerType());
    Assert.assertEquals("Rating", new Float(5), module.getRating());
    Assert.assertEquals("URL of Item", new URL("http://earth.google.com/"), module.getUrlOfItemBeingReviewed());

}
 
开发者ID:rometools,项目名称:rome,代码行数:27,代码来源:GoogleBaseParserTest.java

示例11: testFile

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
private void testFile(final String filename) throws Exception {
    final File feed = new File(getTestFile(filename));
    final SyndFeedInput input = new SyndFeedInput();
    final SyndFeed syndfeed = input.build(new XmlReader(feed.toURI().toURL()));

    final SyndFeedOutput output = new SyndFeedOutput();
    final File outfeed = new File("target/" + feed.getName());
    output.output(syndfeed, outfeed);

    final SyndFeed syndCheck = input.build(new XmlReader(outfeed.toURI().toURL()));
    LOG.debug(syndCheck.getModule(AbstractITunesObject.URI).toString());
    assertEquals("Feed Level: ", syndfeed.getModule(AbstractITunesObject.URI).toString(), syndCheck.getModule(AbstractITunesObject.URI).toString());

    final List<SyndEntry> syndEntries = syndfeed.getEntries();
    final List<SyndEntry> syndChecks = syndCheck.getEntries();

    for (int i = 0; i < syndEntries.size(); i++) {
        final SyndEntry entry = syndEntries.get(i);
        final SyndEntry check = syndChecks.get(i);
        LOG.debug("Original: {}", entry.getModule(AbstractITunesObject.URI));
        LOG.debug("Check:    {}", check.getModule(AbstractITunesObject.URI));
        assertEquals("Entry Level: ", entry.getModule(AbstractITunesObject.URI).toString(), check.getModule(AbstractITunesObject.URI).toString());
    }
}
 
开发者ID:rometools,项目名称:rome-modules,代码行数:25,代码来源:ITunesGeneratorTest.java

示例12: testReadMainSpec

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
public void testReadMainSpec() throws IOException, FeedException {
    final SyndFeed feed = getSyndFeed("thr/threading-main.xml");
    List<SyndEntry> entries = feed.getEntries();
    SyndEntry parentEntry = entries.get(0);
    assertEquals("should be the parent entry", "My original entry", parentEntry.getTitle());
    assertNull(parentEntry.getModule(ThreadingModule.URI));

    SyndEntry replyEntry = entries.get(1);
    assertEquals("should be the reply entry", "A response to the original", replyEntry.getTitle());
    Module module = replyEntry.getModule(ThreadingModule.URI);
    assertNotNull(module);
    ThreadingModule threadingModule = (ThreadingModule) module;
    assertEquals("tag:example.org,2005:1", threadingModule.getRef());
    assertEquals("application/xhtml+xml", threadingModule.getType());
    assertEquals("http://www.example.org/entries/1", threadingModule.getHref());
    assertNull(threadingModule.getSource());
}
 
开发者ID:rometools,项目名称:rome-modules,代码行数:18,代码来源:ThreadingModuleTest.java

示例13: getRecentEntries

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
private ArrayList<SyndEntry> getRecentEntries(int daysSpan) throws IOException, FeedException {
    ArrayList<SyndEntry> entries = new ArrayList<>();

    SyndFeed feed = getFeed();
    for (SyndEntry entry : feed.getEntries()) {
        if (getDaysFromPublication(entry.getPublishedDate()) <= daysSpan) {
            entries.add(entry);
        } else {
            break;
        }
    }

    return entries;
}
 
开发者ID:mapbox,项目名称:mapbox-assistant-example,代码行数:15,代码来源:BlogComponent.java

示例14: loadXmlFromNetwork

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
private List<SyndEntry> loadXmlFromNetwork(String urlString, Feed feed) throws XmlPullParserException, IOException, ParseException {
    SyndFeed f = null;
    try {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document doc = db.parse(new InputSource(new URL(urlString).openStream()));

        f = new SyndFeedInput().build(doc);
        return f.getEntries();
    } catch (FeedException | ParserConfigurationException | SAXException e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:ccrama,项目名称:Slide-RSS,代码行数:15,代码来源:CheckForPosts.java

示例15: readFeeds

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
public List<LinkBean> readFeeds(FeedBean feedBean){

        List<LinkBean> feeds = new ArrayList<LinkBean>();

        try {
            URL url = new URL(feedBean.getUrl());
            SyndFeedInput input = new SyndFeedInput();
            SyndFeed feed = input.build(new XmlReader(url));

            List<SyndEntry> entryList = feed.getEntries();

            for(SyndEntry syndEntry : entryList){
                URL linkUrl = new URL(syndEntry.getLink());

                LinkBean linkBean = new LinkBean();
                linkBean.setTitle(syndEntry.getTitle());
                linkBean.setUrl(linkUrl);
                linkBean.setPublicationDate(syndEntry.getPublishedDate());
                linkBean.setSent(false);
                linkBean.setSubreddit(feedBean.getSubreddit());
                linkBean.setFeedId(feedBean.getId());

                feeds.add(linkBean);
            }
            return feeds;
        } catch (Exception e) {
            logger.error(e.getMessage(),e);
        }
        return feeds;
    }
 
开发者ID:vitalijzad,项目名称:java-rss-for-reddit,代码行数:31,代码来源:RSSFeedReader.java


注:本文中的com.rometools.rome.feed.synd.SyndFeed.getEntries方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。