本文整理汇总了Java中com.sun.syndication.feed.synd.SyndFeed.setFeedType方法的典型用法代码示例。如果您正苦于以下问题:Java SyndFeed.setFeedType方法的具体用法?Java SyndFeed.setFeedType怎么用?Java SyndFeed.setFeedType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.syndication.feed.synd.SyndFeed
的用法示例。
在下文中一共展示了SyndFeed.setFeedType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: doGet
import com.sun.syndication.feed.synd.SyndFeed; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType("rss_2.0");
feed.setTitle("WildFly-Camel Test RSS Feed");
feed.setLink("http://localhost:8080/rss-tests");
feed.setDescription("Test RSS feed for the camel-rss component");
List<SyndEntry> entries = new ArrayList<>();
for (int i = 1; i <= 5; i++) {
entries.add(createFeedEntry("Test entry: ", "Test content: ", i));
}
feed.setEntries(entries);
SyndFeedOutput output = new SyndFeedOutput();
try {
output.output(feed, response.getWriter());
} catch (FeedException e) {
throw new IllegalStateException("Error generating RSS feed", e);
}
}
示例3: main
import com.sun.syndication.feed.synd.SyndFeed; //导入方法依赖的package包/类
public static void main(String[] args) {
boolean ok = false;
if (args.length==2) {
try {
String outputType = args[0];
URL feedUrl = new URL(args[1]);
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(feedUrl));
feed.setFeedType(outputType);
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed,new PrintWriter(System.out));
ok = true;
}
catch (Exception ex) {
System.out.println("ERROR: "+ex.getMessage());
}
}
if (!ok) {
System.out.println();
System.out.println("Converter converts between syndication feeds types.");
System.out.println("The first parameter must be the feed type to convert to.");
System.out.println(" [valid values are: rss_0.9, rss_0.91, rss_0.92, rss_0.93, ]");
System.out.println(" [ rss_0.94, rss_1.0, rss_2.0 & atom_0.3 ]");
System.out.println("The second parameter must be the URL of the feed to convert.");
System.out.println();
}
}
示例4: rssFeed
import com.sun.syndication.feed.synd.SyndFeed; //导入方法依赖的package包/类
@RequestMapping("/rss")
public void rssFeed(HttpServletResponse response) throws IOException, FeedException {
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType("atom_1.0");
feed.setEntries(new LinkedList());
podcastEpisodeService.allPodcasts().forEach(podcastEpisode -> {
feed.getEntries().add(podcastEpisode.getSyndEntry());
});
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, response.getWriter());
}
示例5: makeRSSFromRSSCorresponList
import com.sun.syndication.feed.synd.SyndFeed; //导入方法依赖的package包/类
/**
* コレポンリストからRSSを生成する.
* @param rssCorresponList コレポンリスト
* @param baseURL BaseURL
* @return RSS
* @throws ServiceAbortException 設定値からRSSを出力する際に例外発生
*/
private String makeRSSFromRSSCorresponList(
List<RSSCorrespon> rssCorresponList, String baseURL) throws ServiceAbortException {
String resultRSS = null;
SyndFeed feed = (SyndFeed) new SyndFeedImpl();
feed.setFeedType(FEED_TYPE);
feed.setTitle(RSS_TITLE);
feed.setLink("");
feed.setDescription("");
List<SyndEntry> entries = new ArrayList<SyndEntry>();
if (rssCorresponList != null) {
for (RSSCorrespon c : rssCorresponList) {
entries.add(makeEntryFromRSSCorrespon(c, baseURL));
}
}
feed.setEntries(entries);
try {
SyndFeedOutput output = new SyndFeedOutput();
resultRSS = output.outputString(feed);
} catch (FeedException e) {
// 設定された値から生成されるXMLが異常だった際に発生. 起こり得ない.
ServiceAbortException sae =
new ServiceAbortException("RSS outputString error");
sae.initCause(e);
throw sae;
}
return resultRSS;
}
示例6: createFeed
import com.sun.syndication.feed.synd.SyndFeed; //导入方法依赖的package包/类
/**
* @param feedFile
* @param seriesId
* @param title
* @param transcodingProfileId
* @return
*/
public SyndFeed createFeed(File feedFile, String seriesId, String title,
String transcodingProfileId) {
final SyndFeed defaultFeed = new SyndFeedImpl();
defaultFeed.setFeedType("rss_2.0");
defaultFeed.setTitle(title);
defaultFeed.setLink(this.applicationURL + PATH_SEPARATOR + transcodingProfileId
+ PATH_SEPARATOR + seriesId + feedFileExtension);
defaultFeed.setDescription("Feed for the MythTV recordings of this program");
File transformedFeedFile = null;
try {
final File feedDirectory = feedFile.getParentFile();
if (!feedDirectory.exists()) {
feedDirectory.mkdirs();
LOGGER.info("Created feed directory: " + feedDirectory.getPath());
}
FileWriter writer = new FileWriter(feedFile);
SyndFeedOutput output = new SyndFeedOutput();
output.output(defaultFeed, writer);
transformedFeedFile = this.generateTransformationFromFeed(feedFile, defaultFeed, seriesId);
return defaultFeed;
} catch (Exception e) {
LOGGER.error("Error rendering feed", e);
if (feedFile.canWrite()) {
feedFile.delete();
}
if (transformedFeedFile != null && transformedFeedFile.canWrite()) {
transformedFeedFile.delete();
}
return null;
}
}
示例7: render
import com.sun.syndication.feed.synd.SyndFeed; //导入方法依赖的package包/类
/**
* <p>render</p>
*
* @return a {@link java.lang.String} object.
*/
public String render() {
SyndFeed feed = this.getFeed();
feed.setFeedType(this.getFeedType());
SyndFeedOutput output = new SyndFeedOutput();
try {
StringWriter writer = new StringWriter();
output.output(feed, writer);
return writer.toString();
} catch (Throwable e) {
log().warn("unable to render feed", e);
return "";
}
}
示例8: rss
import com.sun.syndication.feed.synd.SyndFeed; //导入方法依赖的package包/类
public String rss() throws IOException, FeedException {
SyndFeed feed = new SyndFeedImpl();
feed.setTitle("hiscores.shmup.com");
feed.setFeedType("rss_2.0");
feed.setDescription("hiscores.shmup.com");
feed.setLink("http://hiscores.shmup.com");
List entries = new ArrayList();
feed.setEntries(entries);
for (Score score : scores) {
SyndEntry entry = new SyndEntryImpl();
entry.setTitle(score.getGameTitle());
entry.setAuthor(score.player.name);
entry.setLink("http://hiscores.shmup.com/score/" + score.id);
SyndContentImpl content = new SyndContentImpl();
content.setValue(score.tweet());
entry.setDescription(content);
entry.setPublishedDate(score.getCreatedAt());
entry.setUpdatedDate(score.getCreatedAt());
SyndEnclosureImpl enclosure = new SyndEnclosureImpl();
enclosure.setUrl(score.game.cover);
enclosure.setType(score.game.getCoverType());
entry.setEnclosures(Lists.newArrayList(enclosure));
entries.add(entry);
}
Writer writer = new StringWriter();
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, writer);
writer.close();
Controller.response().setContentType("application/rss+xml");
return writer.toString();
}
示例9: testSyndFeedNotEqual
import com.sun.syndication.feed.synd.SyndFeed; //导入方法依赖的package包/类
public void testSyndFeedNotEqual() throws Exception {
SyndFeed feed1 = getCachedSyndFeed();
SyndFeed feed2 = getSyndFeed();
feed2.setFeedType("dummy");
assertFalse(feed1.equals(feed2));
}
示例10: main
import com.sun.syndication.feed.synd.SyndFeed; //导入方法依赖的package包/类
public static void main(String[] args) {
boolean ok = false;
if (args.length>=2) {
try {
String outputType = args[0];
SyndFeed aggrFeed = new SyndFeedImpl();
aggrFeed.setFeedType(outputType);
aggrFeed.setTitle("Aggregated Feed");
aggrFeed.setDescription("Anonymous Aggregated Feed");
aggrFeed.setAuthor("anonymous");
aggrFeed.setLink("http://www.anonymous.com");
List entries = new ArrayList();
aggrFeed.setEntries(entries);
for (int i=1;i<args.length;i++) {
URL feedUrl = new URL(args[i]);
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(feedUrl));
entries.addAll(feed.getEntries());
}
SyndFeedOutput output = new SyndFeedOutput();
output.output(aggrFeed,new PrintWriter(System.out));
ok = true;
}
catch (Exception ex) {
System.out.println("ERROR: "+ex.getMessage());
}
}
if (!ok) {
System.out.println();
System.out.println("FeedAggregator aggregates different feeds into a single one.");
System.out.println("The first parameter must be the feed type for the aggregated feed.");
System.out.println(" [valid values are: rss_0.9, rss_0.91, rss_0.92, rss_0.93, ]");
System.out.println(" [ rss_0.94, rss_1.0, rss_2.0 & atom_0.3 ]");
System.out.println("The second to last parameters are the URLs of feeds to aggregate.");
System.out.println();
}
}
示例11: generateBlogRssFeed
import com.sun.syndication.feed.synd.SyndFeed; //导入方法依赖的package包/类
public static Map<String, Object> generateBlogRssFeed(DispatchContext dctx, Map<String, ? extends Object> context) {
GenericValue userLogin = (GenericValue) context.get("userLogin");
String contentId = (String) context.get("blogContentId");
String entryLink = (String) context.get("entryLink");
String feedType = (String) context.get("feedType");
Locale locale = (Locale) context.get("locale");
// create the main link
String mainLink = (String) context.get("mainLink");
mainLink = mainLink + "?blogContentId=" + contentId;
LocalDispatcher dispatcher = dctx.getDispatcher();
Delegator delegator = dctx.getDelegator();
// get the main blog content
GenericValue content = null;
try {
content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
if (content == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"ContentCannotGenerateBlogRssFeed",
UtilMisc.toMap("contentId", contentId), locale));
}
// create the feed
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType(feedType);
feed.setLink(mainLink);
feed.setTitle(content.getString("contentName"));
feed.setDescription(content.getString("description"));
feed.setEntries(generateEntryList(dispatcher, delegator, contentId, entryLink, locale, userLogin));
Map<String, Object> resp = ServiceUtil.returnSuccess();
resp.put("wireFeed", feed.createWireFeed());
return resp;
}
示例12: generateBlogRssFeed
import com.sun.syndication.feed.synd.SyndFeed; //导入方法依赖的package包/类
public static Map<String, Object> generateBlogRssFeed(DispatchContext dctx, Map<String, ? extends Object> context) {
GenericValue userLogin = (GenericValue) context.get("userLogin");
String contentId = (String) context.get("blogContentId");
String entryLink = (String) context.get("entryLink");
String feedType = (String) context.get("feedType");
Locale locale = (Locale) context.get("locale");
// create the main link
String mainLink = (String) context.get("mainLink");
mainLink = mainLink + "?blogContentId=" + contentId;
LocalDispatcher dispatcher = dctx.getDispatcher();
Delegator delegator = dctx.getDelegator();
// get the main blog content
GenericValue content = null;
try {
content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
if (content == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"ContentCannotGenerateBlogRssFeed",
UtilMisc.toMap("contentId", contentId), locale));
}
// create the feed
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType(feedType);
feed.setLink(mainLink);
feed.setTitle(content.getString("contentName"));
feed.setDescription(content.getString("description"));
feed.setEntries(generateEntryList(dispatcher, delegator, contentId, entryLink, locale, userLogin));
Map<String, Object> resp = ServiceUtil.returnSuccess();
resp.put("wireFeed", feed.createWireFeed());
return resp;
}