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


Java SyndEntryImpl.getTitle方法代码示例

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


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

示例1: readFeed

import com.sun.syndication.feed.synd.SyndEntryImpl; //导入方法依赖的package包/类
/**
 * Reads a Gitblit RSS feed.
 * 
 * @param url
 *            the url of the Gitblit server
 * @param parameters
 *            the list of RSS parameters
 * @param repository
 *            the repository name
 * @param username
 * @param password
 * @return a list of SyndicationModel entries
 * @throws {@link IOException}
 */
private static List<FeedEntryModel> readFeed(String url, List<String> parameters,
		String repository, String branch, String username, char[] password) throws IOException {
	// build url
	StringBuilder sb = new StringBuilder();
	sb.append(MessageFormat.format("{0}" + Constants.SYNDICATION_PATH + "{1}", url, repository));
	if (parameters.size() > 0) {
		boolean first = true;
		for (String parameter : parameters) {
			if (first) {
				sb.append('?');
				first = false;
			} else {
				sb.append('&');
			}
			sb.append(parameter);
		}
	}
	String feedUrl = sb.toString();
	URLConnection conn = ConnectionUtils.openReadConnection(feedUrl, username, password);
	InputStream is = conn.getInputStream();
	SyndFeedInput input = new SyndFeedInput();
	SyndFeed feed = null;
	try {
		feed = input.build(new XmlReader(is));
	} catch (FeedException f) {
		throw new GitBlitException(f);
	}
	is.close();
	List<FeedEntryModel> entries = new ArrayList<FeedEntryModel>();
	for (Object o : feed.getEntries()) {
		SyndEntryImpl entry = (SyndEntryImpl) o;
		FeedEntryModel model = new FeedEntryModel();
		model.repository = repository;
		model.branch = branch;
		model.title = entry.getTitle();
		model.author = entry.getAuthor();
		model.published = entry.getPublishedDate();
		model.link = entry.getLink();
		model.content = entry.getDescription().getValue();
		model.contentType = entry.getDescription().getType();
		if (entry.getCategories() != null && entry.getCategories().size() > 0) {
			List<String> tags = new ArrayList<String>();
			for (Object p : entry.getCategories()) {
				SyndCategory cat = (SyndCategory) p;
				tags.add(cat.getName());
			}
			model.tags = tags;
		}
		entries.add(model);
	}
	return entries;
}
 
开发者ID:warpfork,项目名称:gitblit,代码行数:67,代码来源:SyndicationUtils.java


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