當前位置: 首頁>>代碼示例>>Java>>正文


Java SyndFeed類代碼示例

本文整理匯總了Java中com.sun.syndication.feed.synd.SyndFeed的典型用法代碼示例。如果您正苦於以下問題:Java SyndFeed類的具體用法?Java SyndFeed怎麽用?Java SyndFeed使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SyndFeed類屬於com.sun.syndication.feed.synd包,在下文中一共展示了SyndFeed類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildChannelMap

import com.sun.syndication.feed.synd.SyndFeed; //導入依賴的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

示例2: extractDocuments

import com.sun.syndication.feed.synd.SyndFeed; //導入依賴的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

示例3: copyInto

import com.sun.syndication.feed.synd.SyndFeed; //導入依賴的package包/類
public void copyInto(WireFeed feed,SyndFeed syndFeed) {
    syndFeed.setModules(ModuleUtils.cloneModules(feed.getModules()));

    syndFeed.setEncoding(feed.getEncoding());
    Channel channel = (Channel) feed;
    syndFeed.setTitle(channel.getTitle());
    syndFeed.setLink(channel.getLink());
    syndFeed.setDescription(channel.getDescription());

    Image image = channel.getImage();
    if (image!=null) {
        syndFeed.setImage(createSyndImage(image));
    }

    List items = channel.getItems();
    if (items!=null) {
        syndFeed.setEntries(createSyndEntries(items));
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:20,代碼來源:ConverterForRSS090.java

示例4: createRealFeed

import com.sun.syndication.feed.synd.SyndFeed; //導入依賴的package包/類
protected WireFeed createRealFeed(String type,SyndFeed syndFeed) {
    Channel channel = new Channel(type);
    channel.setModules(ModuleUtils.cloneModules(syndFeed.getModules()));

    channel.setEncoding(syndFeed.getEncoding());

    channel.setTitle(syndFeed.getTitle());
    channel.setLink(syndFeed.getLink());
    channel.setDescription(syndFeed.getDescription());
    SyndImage sImage = syndFeed.getImage();
    if (sImage!=null) {
        channel.setImage(createRSSImage(sImage));
    }

    List sEntries = syndFeed.getEntries();
    if (sEntries!=null) {
        channel.setItems(createRSSItems(sEntries));
    }
    return channel;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:21,代碼來源:ConverterForRSS090.java

示例5: copyInto

import com.sun.syndication.feed.synd.SyndFeed; //導入依賴的package包/類
public void copyInto(WireFeed feed,SyndFeed syndFeed) {
    Channel channel = (Channel) feed;
    super.copyInto(channel,syndFeed);
    syndFeed.setLanguage(channel.getLanguage());        //c
    syndFeed.setCopyright(channel.getCopyright());      //c
    Date pubDate = channel.getPubDate();
    if (pubDate!=null) {
        syndFeed.setPublishedDate(pubDate);     //c
    }

    String author = channel.getManagingEditor();
    if (author!=null) {    
        List creators = ((DCModule) syndFeed.getModule(DCModule.URI)).getCreators();
        if (!creators.contains(author)) {
            Set s = new HashSet(); // using a set to remove duplicates
            s.addAll(creators);    // DC creators
            s.add(author);         // feed native author
            creators.clear();
            creators.addAll(s);
        }
    }

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:24,代碼來源:ConverterForRSS091Userland.java

示例6: main

import com.sun.syndication.feed.synd.SyndFeed; //導入依賴的package包/類
public static void main(String[] args) {
    boolean ok = false;
    if (args.length==1) {
        try {
            URL feedUrl = new URL(args[0]);
            SyndFeedInput input = new SyndFeedInput();

            SyndFeed feed = input.build(new XmlReader(feedUrl));

            System.out.println(feed);

            ok = true;
        }
        catch (Exception ex) {
            ex.printStackTrace();
            System.out.println("ERROR: "+ex.getMessage());
        }
    }

    if (!ok) {
        System.out.println();
        System.out.println("FeedReader reads and prints any RSS/Atom feed type.");
        System.out.println("The first parameter must be the URL of the feed to read.");
        System.out.println();
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:27,代碼來源:FeedReader.java

示例7: getAllBuildsFeed

import com.sun.syndication.feed.synd.SyndFeed; //導入依賴的package包/類
/**
 * Returns a feed for all builds that are allowed for a given user.
 *
 * @param userID for that to return feeds.
 *
 * @return a feed for all builds that are allowed for the given user.
 */
public SyndFeed getAllBuildsFeed(final int userID) {

  final List buildStatusList = org.parabuild.ci.security.SecurityManager.getInstance().getFeedBuildStatuses(userID);

  // traverse build statuses
  final List entries = new ArrayList(11);
  final BuildStatusURLGenerator urlGenerator = new BuildStatusURLGenerator();
  final ConfigurationManager cm = ConfigurationManager.getInstance();
  for (final Iterator i = buildStatusList.iterator(); i.hasNext();) {
    final int activeBuildID = ((BuildState)i.next()).getActiveBuildID();
    entries.addAll(getBuildEntries(cm, activeBuildID, urlGenerator));
  }

  // create feed and set collected entries
  final SyndFeed feed = new SyndFeedImpl();
  feed.setTitle("Parabuild Published Result Feed");
  feed.setLink(urlGenerator.makeBuildListURL());
  feed.setDescription("This feed provides information about published results at Parabuild server");
  feed.setEntries(entries);

  // return result
  return feed;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:31,代碼來源:PublishedResultFeedGenerator.java

示例8: getAllBuildsFeed

import com.sun.syndication.feed.synd.SyndFeed; //導入依賴的package包/類
/**
 * Returns a feed for all builds that are allowed for a given user.
 *
 * @param userID for that to return feeds.
 * @return a feed for all builds that are allowed for the given user.
 */
public SyndFeed getAllBuildsFeed(final int userID) {

  final List buildStatusList = SecurityManager.getInstance().getFeedBuildStatuses(userID);

  // traverse build statuses
  final List entries = new ArrayList(1);
  final BuildStatusURLGenerator urlGenerator = new BuildStatusURLGenerator();
  final ConfigurationManager cm = ConfigurationManager.getInstance();
  for (final Iterator i = buildStatusList.iterator(); i.hasNext();) {
    final int activeBuildID = ((BuildState) i.next()).getActiveBuildID();
    entries.addAll(getBuildEntries(cm, activeBuildID, urlGenerator));
  }

  // create feed and set collected entries
  final SyndFeed feed = new SyndFeedImpl();
  feed.setTitle("Parabuild Feed");
  feed.setLink(urlGenerator.makeBuildListURL());
  feed.setDescription("This feed provides information about build statuses at Parabuild server");
  feed.setEntries(entries);

  // return result
  return feed;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:30,代碼來源:FeedGenerator.java

示例9: execute

import com.sun.syndication.feed.synd.SyndFeed; //導入依賴的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

示例10: generateFeed

import com.sun.syndication.feed.synd.SyndFeed; //導入依賴的package包/類
public SyndFeed generateFeed( String title, String description, List<RssFeedEntry> dataEntries )
{
    if( dataEntries.size() ==  0 )
    {
        log.debug( "No updates found, feed not generated." );
        return null;
    }
    
    SyndFeed feed = new SyndFeedImpl();
    feed.setTitle( title );        
    feed.setDescription( description );
    feed.setLanguage( DEFAULT_LANGUAGE );
    feed.setPublishedDate( dataEntries.get( dataEntries.size() - 1 ).getPublishedDate() );
    feed.setFeedType( DEFAULT_FEEDTYPE );
    feed.setEntries( getEntries( dataEntries ) );

    log.debug( "Finished generating the feed \'{}\'.", title );
    
    return feed;
}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:21,代碼來源:RssFeedGenerator.java

示例11: SyndEntryAdapter

import com.sun.syndication.feed.synd.SyndFeed; //導入依賴的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

示例12: aggregate

import com.sun.syndication.feed.synd.SyndFeed; //導入依賴的package包/類
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
    if (oldExchange == null) {
        return newExchange;
    }
    SyndFeed oldFeed = oldExchange.getIn().getBody(SyndFeed.class);
    SyndFeed newFeed = newExchange.getIn().getBody(SyndFeed.class);
    if (oldFeed != null && newFeed != null) {                
        List<SyndEntryImpl> oldEntries = CastUtils.cast(oldFeed.getEntries());                  
        List<SyndEntryImpl> newEntries = CastUtils.cast(newFeed.getEntries());
        List<SyndEntryImpl> mergedList = new ArrayList<SyndEntryImpl>(oldEntries.size() + newEntries.size());
        mergedList.addAll(oldEntries);
        mergedList.addAll(newEntries);
        oldFeed.setEntries(mergedList);    
    } else {
        log.debug("Could not merge exchanges. One body was null.");
    }
    return oldExchange;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:19,代碼來源:AggregateRssFeedStrategy.java

示例13: testGrabbingListOfEntries

import com.sun.syndication.feed.synd.SyndFeed; //導入依賴的package包/類
@Test
public void testGrabbingListOfEntries() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(1);
    mock.assertIsSatisfied();

    Exchange exchange = mock.getExchanges().get(0);
    Message in = exchange.getIn();
    assertNotNull(in);
    assertTrue(in.getBody() instanceof SyndFeed);
    assertTrue(in.getHeader(RssConstants.RSS_FEED) instanceof SyndFeed);

    SyndFeed feed = in.getHeader(RssConstants.RSS_FEED, SyndFeed.class);
    assertTrue(feed.getAuthor().contains("Jonathan Anstey"));

    SyndFeed body = in.getBody(SyndFeed.class);
    assertEquals(10, body.getEntries().size());
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:19,代碼來源:RssPollingConsumerTest.java

示例14: testCreateNullHeadlineAndLink

import com.sun.syndication.feed.synd.SyndFeed; //導入依賴的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

示例15: getFeedContent

import com.sun.syndication.feed.synd.SyndFeed; //導入依賴的package包/類
/**
 * Get the feed content
 * @param request
 * @param response
 * @return Map of params or null if any required data is missing
 */
private SyndFeed getFeedContent(RenderRequest request, RenderResponse response) {
	
	SyndFeed feed;
	
	//check cache, otherwise get fresh
	//we use the feedUrl as the cacheKey
	String feedUrl = getConfiguredFeedUrl(request);
	if(StringUtils.isBlank(feedUrl)) {
		log.debug("No feed URL configured");
		doError("error.no.config", "error.heading.config", getPortletModeUrl(response, PortletMode.EDIT), request, response);
		return null;
	}
	
	String cacheKey = feedUrl;
	
	feed = feedCache.get(cacheKey);
	if(feed != null) {
		log.debug("Fetching data from feed cache for: " + cacheKey);
	} else {
		//get from remote
		feed = getRemoteFeed(feedUrl, request, response);
	}
	
	return feed;
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:32,代碼來源:SimpleRSSPortlet.java


注:本文中的com.sun.syndication.feed.synd.SyndFeed類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。