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


Java SyndEntry类代码示例

本文整理汇总了Java中com.sun.syndication.feed.synd.SyndEntry的典型用法代码示例。如果您正苦于以下问题:Java SyndEntry类的具体用法?Java SyndEntry怎么用?Java SyndEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: mergeAuthors

import com.sun.syndication.feed.synd.SyndEntry; //导入依赖的package包/类
public static void mergeAuthors(SyndEntry entry) {
    if (CollectionUtils.isEmpty(entry.getAuthors())) {
        entry.setAuthors(Collections.singletonList(entry.getAuthor()));
    }
}
 
开发者ID:jtanza,项目名称:rufus,代码行数:6,代码来源:FeedUtils.java

示例2: buildChannelMap

import com.sun.syndication.feed.synd.SyndEntry; //导入依赖的package包/类
private Map<Channel, List<Document>> buildChannelMap(long userId) {
    List<Source> sources;
    if (userId == PUB_USER_KEY) {
        sources = articleDao.getPublicSources();
    } else if (articleDao.hasSubscriptions(userId)) {
        sources = articleDao.getSources(userId);
    } else {
        return Collections.emptyMap();
    }

    List<RufusFeed> requests = sources.parallelStream().map(RufusFeed::generate).collect(Collectors.toList());

    Map<Channel, List<Document>> ret = new HashMap<>();
    requests.stream().filter(r -> r.getFeed() != null).forEach(r -> {
        Pair<SyndFeed, List<SyndEntry>> synd = feedPair(r);
        ret.put(Channel.of(
            synd.getKey().getTitle(),
            synd.getKey().getLanguage(),
            synd.getKey().getLink(),
            r.getSource()),
            extractDocuments(synd));
    });

    return ret;
}
 
开发者ID:jtanza,项目名称:rufus,代码行数:26,代码来源:FeedProcessorImpl.java

示例3: extractDocuments

import com.sun.syndication.feed.synd.SyndEntry; //导入依赖的package包/类
private static List<Document> extractDocuments(Pair<SyndFeed, List<SyndEntry>> feedEntry) {
    List<Document> ret = new ArrayList<>();
    feedEntry.getRight().forEach(e -> {
        FeedUtils.mergeAuthors(e);
        String description = e.getDescription() != null ? FeedUtils.clean(e.getDescription().getValue()) : StringUtils.EMPTY;
        if (description.length() > FeedConstants.MAX_DESCRIP_LEN) {
            description = FeedUtils.truncate(description, FeedConstants.MAX_DESCRIP_LEN);
        }
        ret.add(Document.of(
            StringEscapeUtils.unescapeHtml4(e.getTitle()),
            e.getPublishedDate(),
            e.getAuthors(),
            description,
            e.getLink(),
            feedEntry.getLeft().getTitle()
        ));
    });
    return ret;
}
 
开发者ID:jtanza,项目名称:rufus,代码行数:20,代码来源:FeedProcessorImpl.java

示例4: createSyndEntry

import com.sun.syndication.feed.synd.SyndEntry; //导入依赖的package包/类
protected SyndEntry createSyndEntry(Item item) {
    SyndEntry syndEntry = super.createSyndEntry(item);

    Description desc = item.getDescription();
    if (desc!=null) {
        SyndContent content = new SyndContentImpl();
        content.setType(desc.getType());
        content.setValue(desc.getValue());
        syndEntry.setDescription(content);

        // contents[0] and description then reference the same content
        //
        List contents = new ArrayList();
        contents.add(content);
        syndEntry.setContents(contents);

    }
    
    return syndEntry;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:ConverterForRSS10.java

示例5: createSyndEntry

import com.sun.syndication.feed.synd.SyndEntry; //导入依赖的package包/类
protected SyndEntry createSyndEntry(Item item) {
    SyndEntry syndEntry = super.createSyndEntry(item);
    Description desc = item.getDescription();
    if (desc!=null) {
        SyndContent content = new SyndContentImpl();
        content.setType(desc.getType());
        content.setValue(desc.getValue());
        syndEntry.setDescription(content);

        // contents[0] and description then reference the same content
        //
        List contents = new ArrayList();
        contents.add(content);
        syndEntry.setContents(contents);

    }
    return syndEntry;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:ConverterForRSS091Userland.java

示例6: execute

import com.sun.syndication.feed.synd.SyndEntry; //导入依赖的package包/类
public void execute(JobExecutionContext context) throws JobExecutionException {
    log.info("Start FetchAtomWorker job");

    EntityManagerFactory emf = (EntityManagerFactory) context.getMergedJobDataMap().get("emf");
    DataManager dm = new DataManager (emf);
    ServletContext scontext = (ServletContext) context.getMergedJobDataMap().get("scontext");

    Iterator it = dm.feeds.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry <String, String[]> pair = (Map.Entry)it.next();
        System.out.println(pair.getKey() + " = " + pair.getValue());

        try {
            URL feedUrl = new URL(pair.getValue()[1]);

            SyndFeedInput input = new SyndFeedInput();
            SyndFeed feed = input.build(new XmlReader(feedUrl));
            for (SyndEntry entry : (List<SyndEntry>) feed.getEntries()) {
                dm.saveNewsItem(entry, pair.getKey());
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
 
开发者ID:juntao,项目名称:dwnewsbot,代码行数:26,代码来源:FetchAtomWorker.java

示例7: SyndEntryAdapter

import com.sun.syndication.feed.synd.SyndEntry; //导入依赖的package包/类
public SyndEntryAdapter(SyndFeed feed, SyndEntry entry) {
    if (entry.getTitleEx() != null) {
        this.title = entry.getTitle();
        this.titleType = entry.getTitleEx().getType();
    }
    if (entry.getDescription() != null) {
        this.description = entry.getDescription().getValue();
        this.descriptionType = entry.getDescription().getType();
    }
    this.uri = entry.getUri();
    this.author = entry.getAuthor();
    this.link = entry.getLink();

    if (entry.getPublishedDate() != null)
        this.publishedDate = ISO_8601_DATE_FORMAT.format(entry.getPublishedDate());
    if (entry.getUpdatedDate() != null)
        this.updatedDate = ISO_8601_DATE_FORMAT.format(entry.getUpdatedDate());
    this.fetchDate = ISO_8601_DATE_FORMAT.format(new Date());

    this.sourceLink = feed.getLink();
    this.sourceUri = feed.getUri();
    this.sourceTitle = feed.getTitle();
    this.language = feed.getLanguage();
    this.sourceType = feed.getFeedType();
}
 
开发者ID:marozau,项目名称:expresso,代码行数:26,代码来源:SyndEntryAdapter.java

示例8: createFeedEntry

import com.sun.syndication.feed.synd.SyndEntry; //导入依赖的package包/类
private @Nonnull SyndEntry createFeedEntry(@Nonnull String extractPageElement, @Nullable String titleSelector,
		@Nullable String linkSelector, @Nullable String authorSelector) {
	SyndEntry entry = new SyndEntryImpl();
	if(titleSelector != null) {
		entry.setTitle(stripHtml(getText(extractPageElement, titleSelector)));
	}
	if(linkSelector != null) {
			entry.setLink(makeAbsolute(getHref(getText(extractPageElement, linkSelector)), pageUrl));
	}
	if(authorSelector != null) {
		entry.setAuthor(stripHtml(getText(extractPageElement, authorSelector)));
	}
	
	entry.setDescription(createFeedContent(extractPageElement));
	return entry;
}
 
开发者ID:rrauschenbach,项目名称:FeedExpander,代码行数:17,代码来源:FeedCreatorImpl.java

示例9: testCreateNullHeadlineAndLink

import com.sun.syndication.feed.synd.SyndEntry; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testCreateNullHeadlineAndLink() throws Exception {
	String createdFeed = new String(createFeedCreator("feeds/valid_page/index.html")
			.createFeed(".headline,.article,.footer", null, null, null)
			.setTitle("Title")
			.build());
	SyndFeedInput input = new SyndFeedInput();
	SyndFeed feed = input.build(new XmlReader(new ByteArrayInputStream(createdFeed.getBytes())));
	assertEquals("Title", feed.getTitle());
	
	List<SyndEntry> entries = feed.getEntries();

	assertEquals(null, entries.get(0).getTitle());
	assertEquals(null, entries.get(0).getLink());
	assertEquals(EMPTY, entries.get(0).getAuthor());
	assertEquals(null, entries.get(1).getTitle());
	assertEquals(null, entries.get(1).getLink());
	assertEquals(EMPTY, entries.get(1).getAuthor());
}
 
开发者ID:rrauschenbach,项目名称:FeedExpander,代码行数:21,代码来源:FeedCreatorTest.java

示例10: createSyndEntry

import com.sun.syndication.feed.synd.SyndEntry; //导入依赖的package包/类
@Override
protected SyndEntry createSyndEntry(Item item, boolean preserveWireItem) {
    SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);

    Description desc = item.getDescription();
    if (desc!=null) {
        SyndContent descContent = new SyndContentImpl();
        descContent.setType(desc.getType());
        descContent.setValue(desc.getValue());
        syndEntry.setDescription(descContent);
    }
    Content cont = item.getContent();
    if (cont!=null) {
        SyndContent contContent = new SyndContentImpl();
        contContent.setType(cont.getType());
        contContent.setValue(cont.getValue());
        List contents = new ArrayList();
        contents.add(contContent);
        syndEntry.setContents(contents);
    }
            
    return syndEntry;
}
 
开发者ID:4thline,项目名称:feeds,代码行数:24,代码来源:ConverterForRSS10.java

示例11: createRSSItem

import com.sun.syndication.feed.synd.SyndEntry; //导入依赖的package包/类
@Override
protected Item createRSSItem(SyndEntry sEntry) {
    Item item = super.createRSSItem(sEntry);

    SyndContent desc = sEntry.getDescription();
    if (desc!=null) {
        item.setDescription(createItemDescription(desc));
    }
    List contents = sEntry.getContents();
    if (contents!=null && contents.size() > 0) {
        item.setContent(createItemContent((SyndContent)contents.get(0)));
    }
    
    String uri = sEntry.getUri();
    if (uri != null) {
        item.setUri(uri);
    }
    
    return item;
}
 
开发者ID:4thline,项目名称:feeds,代码行数:21,代码来源:ConverterForRSS10.java

示例12: createRSSItem

import com.sun.syndication.feed.synd.SyndEntry; //导入依赖的package包/类
@Override
protected Item createRSSItem(SyndEntry sEntry) {
    Item item = super.createRSSItem(sEntry);

    SyndContent sContent = sEntry.getDescription();

    if (sContent != null) {
        item.setDescription(createItemDescription(sContent));
    }

    List contents = sEntry.getContents();

    if ((contents != null) && (contents.size() > 0)) {
        SyndContent syndContent = (SyndContent) contents.get(0);
        Content cont = new Content();
        cont.setValue(syndContent.getValue());
        cont.setType(syndContent.getType());
        item.setContent(cont);
    }

    return item;
}
 
开发者ID:4thline,项目名称:feeds,代码行数:23,代码来源:ConverterForRSS091Userland.java

示例13: createSyndEntry

import com.sun.syndication.feed.synd.SyndEntry; //导入依赖的package包/类
@Override
protected SyndEntry createSyndEntry(Item item, boolean preserveWireItem) {
    SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
    Description desc = item.getDescription();

    if (desc != null) {
        SyndContent descContent = new SyndContentImpl();
        descContent.setType(desc.getType());
        descContent.setValue(desc.getValue());
        syndEntry.setDescription(descContent);
    }

    Content cont = item.getContent();

    if (cont != null) {
        SyndContent content = new SyndContentImpl();
        content.setType(cont.getType());
        content.setValue(cont.getValue());

        List syndContents = new ArrayList();
        syndContents.add(content);
        syndEntry.setContents(syndContents);
    }

    return syndEntry;
}
 
开发者ID:4thline,项目名称:feeds,代码行数:27,代码来源:ConverterForRSS091Userland.java

示例14: createSyndEntry

import com.sun.syndication.feed.synd.SyndEntry; //导入依赖的package包/类
@Override
protected SyndEntry createSyndEntry(Item item, boolean preserveWireItem) {
    SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
    List cats =  item.getCategories();
    if (cats.size()>0) {
        Set s = new LinkedHashSet();                // using a set to remove duplicates and use a LinkedHashSet to try to retain the document order
        s.addAll(createSyndCategories(cats)); // feed native categories (as syndcat)
        s.addAll(syndEntry.getCategories());   // DC subjects (as syndcat)
        syndEntry.setCategories(new ArrayList(s));    //c
    }
    List enclosures = item.getEnclosures();
    if (enclosures.size()>0) {
        syndEntry.setEnclosures(createSyndEnclosures(enclosures));
    }
    return syndEntry;
}
 
开发者ID:4thline,项目名称:feeds,代码行数:17,代码来源:ConverterForRSS092.java

示例15: gatherLinks

import com.sun.syndication.feed.synd.SyndEntry; //导入依赖的package包/类
private TreeMap gatherLinks(String section) {
    TreeMap linkMap = new TreeMap(Collections.reverseOrder());
    //for sites that support rss we do rss
    SyndFeed feed = getSectionLinksFromRssFeed(section);
    if (feed != null) {
        for (SyndEntry anEntry : (List<SyndEntry>) feed.getEntries()) {
            String aLink = anEntry.getLink();
            if (aLink.contains(ampLiteral)) {
                aLink = aLink.replace(ampLiteral, "");
            }
            if (!shoudRemove(anEntry)) {
                linkMap.put(aLink, aLink);
            }
        }
    }
    //for sites that do not have or do not support
    return linkMap;
}
 
开发者ID:javapapo,项目名称:crawly,代码行数:19,代码来源:Crawly.java


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