本文整理了Java中com.rometools.rome.feed.WireFeed
类的一些代码示例,展示了WireFeed
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WireFeed
类的具体详情如下:
包路径:com.rometools.rome.feed.WireFeed
类名称:WireFeed
[英]Parent class of the RSS (Channel) and Atom (Feed) feed beans.
NOTE: We don't like this class at this package level but the alternative would have been a proliferation of packages (one more level to hold atom and rss package with this class just in that package).
The format of the 'type' property must be [FEEDNAME]_[FEEDVERSION] with the FEEDNAME in lower case, for example: rss_0.9, rss_0.93, atom_0.3
[中]RSS(通道)和Atom(提要)提要bean的父类。
注意:我们不喜欢在这个包级别上使用这个类,但另一种选择是包的激增(再增加一个级别,将这个类的atom和rss包放在那个包中)。
“type”属性的格式必须是[FEEDNAME][FEEDVERSION],FEEDNAME的大小写为小写,例如:rss_0.9、rss_0.93、atom_0.3
代码示例来源:origin: spring-projects/spring-framework
@Override
protected void writeInternal(T wireFeed, HttpOutputMessage outputMessage)
throws IOException, HttpMessageNotWritableException {
Charset charset = (StringUtils.hasLength(wireFeed.getEncoding()) ?
Charset.forName(wireFeed.getEncoding()) : DEFAULT_CHARSET);
MediaType contentType = outputMessage.getHeaders().getContentType();
if (contentType != null) {
contentType = new MediaType(contentType.getType(), contentType.getSubtype(), charset);
outputMessage.getHeaders().setContentType(contentType);
}
WireFeedOutput feedOutput = new WireFeedOutput();
try {
Writer writer = new OutputStreamWriter(outputMessage.getBody(), charset);
feedOutput.output(wireFeed, writer);
}
catch (FeedException ex) {
throw new HttpMessageNotWritableException("Could not write WireFeed: " + ex.getMessage(), ex);
}
}
代码示例来源:origin: spring-projects/spring-framework
@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();
}
代码示例来源:origin: rometools/rome
@Override
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
syndFeed.setModules(ModuleUtils.cloneModules(feed.getModules()));
final List<Element> foreignMarkup = feed.getForeignMarkup();
if (!foreignMarkup.isEmpty()) {
syndFeed.setForeignMarkup(foreignMarkup);
}
syndFeed.setStyleSheet(feed.getStyleSheet());
syndFeed.setEncoding(feed.getEncoding());
final Channel channel = (Channel) feed;
syndFeed.setTitle(channel.getTitle());
syndFeed.setLink(channel.getLink());
syndFeed.setDescription(channel.getDescription());
final Image image = channel.getImage();
if (image != null) {
syndFeed.setImage(createSyndImage(image));
}
final List<Item> items = channel.getItems();
if (items != null) {
syndFeed.setEntries(createSyndEntries(items, syndFeed.isPreservingWireFeed()));
}
}
代码示例来源:origin: rometools/rome
/**
* Creates a SyndFeedImpl and populates all its properties out of the given RSS Channel or Atom
* Feed properties, while optionally preserving the WireFeed for access via the
* orignalWireFeed() method.
*/
public SyndFeedImpl(final WireFeed feed, final boolean preserveWireFeed) {
this(SyndFeed.class, IGNORE_PROPERTIES);
if (preserveWireFeed) {
wireFeed = feed;
this.preserveWireFeed = preserveWireFeed;
}
if (feed != null) {
feedType = feed.getFeedType();
final Converter converter = CONVERTERS.getConverter(feedType);
if (converter == null) {
throw new IllegalArgumentException("Invalid feed type [" + feedType + "]");
}
converter.copyInto(feed, this);
}
}
代码示例来源:origin: com.rometools/rome
/**
* After we parse the feed we put "rss_2.0" in it (so converters and generators work) this
* parser is a phantom.
*
*/
@Override
protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {
final WireFeed wFeed = super.parseChannel(rssRoot, locale);
wFeed.setFeedType("rss_2.0");
return wFeed;
}
代码示例来源:origin: rometools/rome
/**
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
* method.
*
* @param other he reference object with which to compare.
* @return <b>true</b> if 'this' object is equal to the 'other' object.
*
*/
@Override
public boolean equals(final Object other) {
if (other == null) {
return false;
}
if (!(other instanceof WireFeed)) {
return false;
}
// can't use foreign markup in equals, due to JDOM equals impl
final List<Element> fm = getForeignMarkup();
setForeignMarkup(((WireFeed) other).getForeignMarkup());
final boolean ret = EqualsBean.beanEquals(this.getClass(), this, other);
// restore foreign markup
setForeignMarkup(fm);
return ret;
}
代码示例来源:origin: rometools/rome
final List<Element> foreignMarkup = feed.getForeignMarkup();
if (!foreignMarkup.isEmpty()) {
syndFeed.setForeignMarkup(foreignMarkup);
代码示例来源:origin: com.rometools/rome
@Override
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
syndFeed.setModules(ModuleUtils.cloneModules(feed.getModules()));
final List<Element> foreignMarkup = feed.getForeignMarkup();
if (!foreignMarkup.isEmpty()) {
syndFeed.setForeignMarkup(foreignMarkup);
}
syndFeed.setStyleSheet(feed.getStyleSheet());
syndFeed.setEncoding(feed.getEncoding());
final Channel channel = (Channel) feed;
syndFeed.setTitle(channel.getTitle());
syndFeed.setLink(channel.getLink());
syndFeed.setDescription(channel.getDescription());
final Image image = channel.getImage();
if (image != null) {
syndFeed.setImage(createSyndImage(image));
}
final List<Item> items = channel.getItems();
if (items != null) {
syndFeed.setEntries(createSyndEntries(items, syndFeed.isPreservingWireFeed()));
}
}
代码示例来源:origin: com.rometools/rome
/**
* Creates a SyndFeedImpl and populates all its properties out of the given RSS Channel or Atom
* Feed properties, while optionally preserving the WireFeed for access via the
* orignalWireFeed() method.
*/
public SyndFeedImpl(final WireFeed feed, final boolean preserveWireFeed) {
this(SyndFeed.class, IGNORE_PROPERTIES);
if (preserveWireFeed) {
wireFeed = feed;
this.preserveWireFeed = preserveWireFeed;
}
if (feed != null) {
feedType = feed.getFeedType();
final Converter converter = CONVERTERS.getConverter(feedType);
if (converter == null) {
throw new IllegalArgumentException("Invalid feed type [" + feedType + "]");
}
converter.copyInto(feed, this);
}
}
代码示例来源:origin: rometools/rome
/**
* After we parse the feed we put "rss_2.0" in it (so converters and generators work) this
* parser is a phantom.
*
*/
@Override
protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {
final WireFeed wFeed = super.parseChannel(rssRoot, locale);
wFeed.setFeedType("rss_2.0");
return wFeed;
}
}
代码示例来源:origin: com.rometools/rome
/**
* Indicates whether some other object is "equal to" this one as defined by the Object equals()
* method.
*
* @param other he reference object with which to compare.
* @return <b>true</b> if 'this' object is equal to the 'other' object.
*
*/
@Override
public boolean equals(final Object other) {
if (other == null) {
return false;
}
if (!(other instanceof WireFeed)) {
return false;
}
// can't use foreign markup in equals, due to JDOM equals impl
final List<Element> fm = getForeignMarkup();
setForeignMarkup(((WireFeed) other).getForeignMarkup());
final boolean ret = EqualsBean.beanEquals(this.getClass(), this, other);
// restore foreign markup
setForeignMarkup(fm);
return ret;
}
代码示例来源:origin: rometools/rome
final List<Element> foreignMarkup = feed.getForeignMarkup();
if (Lists.isNotEmpty(foreignMarkup)) {
syndFeed.setForeignMarkup(foreignMarkup);
代码示例来源:origin: org.springframework/spring-web
@Override
protected void writeInternal(T wireFeed, HttpOutputMessage outputMessage)
throws IOException, HttpMessageNotWritableException {
Charset charset = (StringUtils.hasLength(wireFeed.getEncoding()) ?
Charset.forName(wireFeed.getEncoding()) : DEFAULT_CHARSET);
MediaType contentType = outputMessage.getHeaders().getContentType();
if (contentType != null) {
contentType = new MediaType(contentType.getType(), contentType.getSubtype(), charset);
outputMessage.getHeaders().setContentType(contentType);
}
WireFeedOutput feedOutput = new WireFeedOutput();
try {
Writer writer = new OutputStreamWriter(outputMessage.getBody(), charset);
feedOutput.output(wireFeed, writer);
}
catch (FeedException ex) {
throw new HttpMessageNotWritableException("Could not write WireFeed: " + ex.getMessage(), ex);
}
}
代码示例来源:origin: org.springframework/spring-webmvc
@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();
}
代码示例来源:origin: com.rometools/rome
/**
* Creates a JDOM document for the given WireFeed.
* <p>
* This method does not use the feed encoding property.
* <p>
* NOTE: All other output methods delegate to this method.
* <p>
*
* @param feed Abstract feed to create JDOM document from. The type of the WireFeed must match
* the type given to the FeedOuptut constructor.
* @return the JDOM document for the given WireFeed.
* @throws IllegalArgumentException thrown if the feed type of the WireFeedOutput and WireFeed
* don't match.
* @throws FeedException thrown if the JDOM document for the feed could not be created.
*
*/
public Document outputJDom(final WireFeed feed) throws IllegalArgumentException, FeedException {
final String type = feed.getFeedType();
final WireFeedGenerator generator = getFeedGenerators().getGenerator(type);
if (generator == null) {
throw new IllegalArgumentException("Invalid feed type [" + type + "]");
}
if (!generator.getType().equals(type)) {
throw new IllegalArgumentException("WireFeedOutput type[" + type + "] and WireFeed type [" + type + "] don't match");
}
return generator.generate(feed);
}
代码示例来源:origin: com.rometools/rome-modules
/**
* After we parse the feed we put "rss_2.0" in it (so converters and generators work) this
* parser is a phantom.
*
*/
@Override
protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {
final WireFeed wFeed = super.parseChannel(rssRoot, locale);
wFeed.setFeedType("rss_2.0");
return wFeed;
}
}
代码示例来源:origin: com.rometools/rome
final List<Element> foreignMarkup = feed.getForeignMarkup();
if (Lists.isNotEmpty(foreignMarkup)) {
syndFeed.setForeignMarkup(foreignMarkup);
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-web
@Override
protected void writeInternal(T wireFeed, HttpOutputMessage outputMessage)
throws IOException, HttpMessageNotWritableException {
Charset charset = (StringUtils.hasLength(wireFeed.getEncoding()) ?
Charset.forName(wireFeed.getEncoding()) : DEFAULT_CHARSET);
MediaType contentType = outputMessage.getHeaders().getContentType();
if (contentType != null) {
contentType = new MediaType(contentType.getType(), contentType.getSubtype(), charset);
outputMessage.getHeaders().setContentType(contentType);
}
WireFeedOutput feedOutput = new WireFeedOutput();
try {
Writer writer = new OutputStreamWriter(outputMessage.getBody(), charset);
feedOutput.output(wireFeed, writer);
}
catch (FeedException ex) {
throw new HttpMessageNotWritableException("Could not write WireFeed: " + ex.getMessage(), ex);
}
}
代码示例来源:origin: apache/servicemix-bundles
@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();
}
代码示例来源:origin: rometools/rome
/**
* Creates a JDOM document for the given WireFeed.
* <p>
* This method does not use the feed encoding property.
* <p>
* NOTE: All other output methods delegate to this method.
* <p>
*
* @param feed Abstract feed to create JDOM document from. The type of the WireFeed must match
* the type given to the FeedOuptut constructor.
* @return the JDOM document for the given WireFeed.
* @throws IllegalArgumentException thrown if the feed type of the WireFeedOutput and WireFeed
* don't match.
* @throws FeedException thrown if the JDOM document for the feed could not be created.
*
*/
public Document outputJDom(final WireFeed feed) throws IllegalArgumentException, FeedException {
final String type = feed.getFeedType();
final WireFeedGenerator generator = getFeedGenerators().getGenerator(type);
if (generator == null) {
throw new IllegalArgumentException("Invalid feed type [" + type + "]");
}
if (!generator.getType().equals(type)) {
throw new IllegalArgumentException("WireFeedOutput type[" + type + "] and WireFeed type [" + type + "] don't match");
}
return generator.generate(feed);
}
内容来源于网络,如有侵权,请联系作者删除!