當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。