• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java WireFeedOutput类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: parseEntry

import com.sun.syndication.io.WireFeedOutput; //导入依赖的package包/类
/**
 * Parse entry from reader.
 */
public static Entry parseEntry(Reader rd, String baseURI)
    throws JDOMException, IOException, IllegalArgumentException, FeedException {
    // Parse entry into JDOM tree
    SAXBuilder builder = new SAXBuilder();
    Document entryDoc = builder.build(rd);
    Element fetchedEntryElement = entryDoc.getRootElement();
    fetchedEntryElement.detach();

    // Put entry into a JDOM document with 'feed' root so that Rome can handle it
    Feed feed = new Feed();
    feed.setFeedType("atom_1.0");
    WireFeedOutput wireFeedOutput = new WireFeedOutput();
    Document feedDoc = wireFeedOutput.outputJDom(feed);
    feedDoc.getRootElement().addContent(fetchedEntryElement);
    
    if (baseURI != null) {
        feedDoc.getRootElement().setAttribute("base", baseURI, Namespace.XML_NAMESPACE);
    }
    
    WireFeedInput input = new WireFeedInput();
    Feed parsedFeed = (Feed)input.build(feedDoc);
    return (Entry)parsedFeed.getEntries().get(0);
}
 
开发者ID:4thline,项目名称:feeds,代码行数:27,代码来源:Atom10Parser.java


示例2: serializeEntry

import com.sun.syndication.io.WireFeedOutput; //导入依赖的package包/类
/**
 * Utility method to serialize an entry to writer.
 */
public static void serializeEntry(Entry entry, Writer writer)
    throws IllegalArgumentException, FeedException, IOException {
    
    // Build a feed containing only the entry
    List entries = new ArrayList();
    entries.add(entry);
    Feed feed1 = new Feed();
    feed1.setFeedType("atom_1.0");
    feed1.setEntries(entries);

    // Get Rome to output feed as a JDOM document
    WireFeedOutput wireFeedOutput = new WireFeedOutput();
    Document feedDoc = wireFeedOutput.outputJDom(feed1);

    // Grab entry element from feed and get JDOM to serialize it
    Element entryElement= (Element)feedDoc.getRootElement().getChildren().get(0);

    XMLOutputter outputter = new XMLOutputter();
    outputter.output(entryElement, writer);
}
 
开发者ID:4thline,项目名称:feeds,代码行数:24,代码来源:Atom10Generator.java


示例3: renderMergedOutputModel

import com.sun.syndication.io.WireFeedOutput; //导入依赖的package包/类
@Override
protected final void renderMergedOutputModel(
		Map<String, Object> model, HttpServletRequest request, HttpServletResponse response)
		throws Exception {

	T wireFeed = newFeed();
	buildFeedMetadata(model, wireFeed, request);
	buildFeedEntries(model, wireFeed, request, response);

	setResponseContentType(request, response);
	if (!StringUtils.hasText(wireFeed.getEncoding())) {
		wireFeed.setEncoding("UTF-8");
	}

	WireFeedOutput feedOutput = new WireFeedOutput();
	ServletOutputStream out = response.getOutputStream();
	feedOutput.output(wireFeed, new OutputStreamWriter(out, wireFeed.getEncoding()));
	out.flush();
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:20,代码来源:AbstractFeedView.java


示例4: writeInternal

import com.sun.syndication.io.WireFeedOutput; //导入依赖的package包/类
@Override
protected void writeInternal(T wireFeed, HttpOutputMessage outputMessage)
		throws IOException, HttpMessageNotWritableException {

	String wireFeedEncoding = wireFeed.getEncoding();
	if (!StringUtils.hasLength(wireFeedEncoding)) {
		wireFeedEncoding = DEFAULT_CHARSET.name();
	}
	MediaType contentType = outputMessage.getHeaders().getContentType();
	if (contentType != null) {
		Charset wireFeedCharset = Charset.forName(wireFeedEncoding);
		contentType = new MediaType(contentType.getType(), contentType.getSubtype(), wireFeedCharset);
		outputMessage.getHeaders().setContentType(contentType);
	}

	WireFeedOutput feedOutput = new WireFeedOutput();
	try {
		Writer writer = new OutputStreamWriter(outputMessage.getBody(), wireFeedEncoding);
		feedOutput.output(wireFeed, writer);
	}
	catch (FeedException ex) {
		throw new HttpMessageNotWritableException("Could not write WireFeed: " + ex.getMessage(), ex);
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:25,代码来源:AbstractWireFeedHttpMessageConverter.java


示例5: init

import com.sun.syndication.io.WireFeedOutput; //导入依赖的package包/类
public void init(ServletContext context) throws EventHandlerException {
    this.context = context;
    this.handler = (RequestHandler) context.getAttribute("_REQUEST_HANDLER_");
    if (this.handler == null) {
        throw new EventHandlerException("No request handler found in servlet context!");
    }

    // get the service event handler
    this.service = new ServiceEventHandler();
    this.service.init(context);
    this.out = new WireFeedOutput();
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:13,代码来源:RomeEventHandler.java


示例6: publishFeedToString

import com.sun.syndication.io.WireFeedOutput; //导入依赖的package包/类
public String publishFeedToString() throws Exception {
	if ( activeRSS != null )
		return new WireFeedOutput().outputString(activeRSS);
	else if ( activeATOM != null )
		return new WireFeedOutput().outputString(activeATOM);
	else
		return null;
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:9,代码来源:CreateFeed.java


示例7: init

import com.sun.syndication.io.WireFeedOutput; //导入依赖的package包/类
public void init(ServletContext context) throws EventHandlerException {
    // get the service event handler
    this.service = new ServiceEventHandler();
    this.service.init(context);
    this.out = new WireFeedOutput();
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:7,代码来源:RomeEventHandler.java


示例8: generatePodcastRSS

import com.sun.syndication.io.WireFeedOutput; //导入依赖的package包/类
/**
 * This method generates the RSS feed
 * 
 * @param siteID
 *            The site id whose feed needs to be generated
 * @param ftyle
 * 			 The feed type (for potential future development) - currently rss 2.0
 * 
 * @return String 
 * 			 The feed document as a String
 */
public String generatePodcastRSS(String siteId, String ftype) {
	final String feedType = (ftype != null) ? ftype : defaultFeedType;
	Date pubDate = null;
	Date lastBuildDate = null;

	// put each podcast entry/episode into a list
	List entries = populatePodcastArray(siteId);

	// Pull first entry if not null in order to establish publish date
	// for entire feed. Pull the second to get lastBuildDate
	if (entries != null) {
		Iterator iter = entries.iterator();

		if (iter.hasNext()) {
			Item firstPodcast = (Item) iter.next();

			pubDate = firstPodcast.getPubDate();

			if (iter.hasNext()) {
				Item nextPodcast = (Item) iter.next();

				lastBuildDate = nextPodcast.getPubDate();
			}
			else {
				// only one, so use the first podcast date
				lastBuildDate = pubDate;
			}

		} 
		else {
			// There are no podcasts to present, so use today
			pubDate = new Date();
			lastBuildDate = pubDate;
		}
	}

	// pull global information for the feed into a Map so
	// can be passed all at once
	Map feedInfo = new HashMap();
	
	feedInfo.put("title", getPodfeedTitle(siteId));
	feedInfo.put("desc", getPodfeedDescription(siteId));
	feedInfo.put("gen", getPodfeedGenerator(siteId));
	
	// This is the URL for the actual feed.
	feedInfo.put("url", ServerConfigurationService.getServerUrl()
			+ Entity.SEPARATOR + "podcasts/site/" + siteId);
	
	feedInfo.put("copyright", getPodfeedCopyright(siteId));
	
	final WireFeed podcastFeed = doSyndication(feedInfo, entries, feedType, 
									pubDate, lastBuildDate);

	final WireFeedOutput wireWriter = new WireFeedOutput();

	try {
		return wireWriter.outputString(podcastFeed);

	} catch (FeedException e) {
		log.error(
				"Feed exception while attempting to write out the final xml file. "
						+ "for site: " + siteId + ". " + e.getMessage(), e);
		throw new PodcastException(e);

	}
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:78,代码来源:BasicPodfeedService.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TestHDFSServerPorts类代码示例发布时间:2022-05-22
下一篇:
Java Binding类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap