本文整理汇总了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);
}
示例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);
}
示例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();
}
示例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);
}
}
示例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();
}
示例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;
}
示例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();
}
示例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);
}
}