本文整理汇总了Java中com.rometools.rome.feed.rss.Channel类的典型用法代码示例。如果您正苦于以下问题:Java Channel类的具体用法?Java Channel怎么用?Java Channel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Channel类属于com.rometools.rome.feed.rss包,在下文中一共展示了Channel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: read
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
@Test
public void read() throws IOException {
InputStream is = getClass().getResourceAsStream("rss.xml");
MockHttpInputMessage inputMessage = new MockHttpInputMessage(is);
inputMessage.getHeaders().setContentType(new MediaType("application", "rss+xml", utf8));
Channel result = converter.read(Channel.class, inputMessage);
assertEquals("title", result.getTitle());
assertEquals("http://example.com", result.getLink());
assertEquals("description", result.getDescription());
List<?> items = result.getItems();
assertEquals(2, items.size());
Item item1 = (Item) items.get(0);
assertEquals("title1", item1.getTitle());
Item item2 = (Item) items.get(1);
assertEquals("title2", item2.getTitle());
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:RssChannelHttpMessageConverterTests.java
示例2: writeOtherCharset
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
@Test
public void writeOtherCharset() throws IOException, SAXException {
Channel channel = new Channel("rss_2.0");
channel.setTitle("title");
channel.setLink("http://example.com");
channel.setDescription("description");
String encoding = "ISO-8859-1";
channel.setEncoding(encoding);
Item item1 = new Item();
item1.setTitle("title1");
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
converter.write(channel, null, outputMessage);
assertEquals("Invalid content-type", new MediaType("application", "rss+xml", Charset.forName(encoding)),
outputMessage.getHeaders().getContentType());
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:RssChannelHttpMessageConverterTests.java
示例3: buildFeedMetadata
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
@Override
protected void buildFeedMetadata(Map<String, Object> model,
Channel feed,
HttpServletRequest request) {
ZoneInfo zoneInfo = (ZoneInfo) model.get("zoneInfo");
@SuppressWarnings("unchecked")
List<Article> articles = (List<Article>) model.get("articles");
if (zoneInfo != null) {
feed.setTitle(zoneInfo.getName() + " kaif.io");
feed.setLink(zoneUrl(zoneInfo.getZone()));
feed.setDescription(zoneInfo.getAliasName() + " 熱門");
feed.setPubDate(buildFeedUpdateTime(articles, zoneInfo.getCreateTime()));
} else {
feed.setTitle("熱門 kaif.io");
feed.setLink(SCHEME_AND_HOST);
feed.setDescription("綜合熱門");
feed.setPubDate(buildFeedUpdateTime(articles, DEFAULT_INSTANT));
}
}
开发者ID:kaif-open,项目名称:kaif,代码行数:20,代码来源:HotArticleRssContentView.java
示例4: copyInto
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
@Override
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
final Channel channel = (Channel) feed;
super.copyInto(channel, syndFeed);
final String uri = channel.getUri();
if (uri != null) {
syndFeed.setUri(uri);
} else {
// if URI is not set use the value for link
final String link = channel.getLink();
syndFeed.setUri(link);
}
}
开发者ID:rometools,项目名称:rome,代码行数:17,代码来源:ConverterForRSS10.java
示例5: createRealFeed
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
@Override
protected WireFeed createRealFeed(final String type, final SyndFeed syndFeed) {
final Channel channel = (Channel) super.createRealFeed(type, syndFeed);
final String uri = syndFeed.getUri();
if (uri != null) {
channel.setUri(uri);
} else {
// if URI is not set use the value for link
final String link = syndFeed.getLink();
channel.setUri(link);
}
return channel;
}
开发者ID:rometools,项目名称:rome,代码行数:17,代码来源:ConverterForRSS10.java
示例6: createRealFeed
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
@Override
protected WireFeed createRealFeed(final String type, final SyndFeed syndFeed) {
final Channel channel = (Channel) super.createRealFeed(type, syndFeed);
channel.setLanguage(syndFeed.getLanguage()); // c
channel.setCopyright(syndFeed.getCopyright()); // c
channel.setPubDate(syndFeed.getPublishedDate()); // c
channel.setDocs(syndFeed.getDocs());
channel.setManagingEditor(syndFeed.getManagingEditor());
channel.setWebMaster(syndFeed.getWebMaster());
channel.setGenerator(syndFeed.getGenerator());
final List<SyndPerson> authors = syndFeed.getAuthors();
if (Lists.isNotEmpty(authors)) {
final SyndPerson author = authors.get(0);
channel.setManagingEditor(author.getName());
}
return channel;
}
开发者ID:rometools,项目名称:rome,代码行数:20,代码来源:ConverterForRSS091Userland.java
示例7: parseChannel
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
@Override
protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {
final Channel channel = (Channel) super.parseChannel(rssRoot, locale);
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
final List<Element> categories = eChannel.getChildren("category", getRSSNamespace());
channel.setCategories(parseCategories(categories));
final Element ttl = eChannel.getChild("ttl", getRSSNamespace());
if (ttl != null && ttl.getText() != null) {
final Integer ttlValue = NumberParser.parseInt(ttl.getText());
if (ttlValue != null) {
channel.setTtl(ttlValue);
}
}
return channel;
}
开发者ID:rometools,项目名称:rome,代码行数:21,代码来源:RSS094Parser.java
示例8: populateChannel
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
@Override
protected void populateChannel(final Channel channel, final Element eChannel) {
super.populateChannel(channel, eChannel);
final String channelUri = channel.getUri();
if (channelUri != null) {
eChannel.setAttribute("about", channelUri, getRDFNamespace());
}
final List<Item> items = channel.getItems();
if (!items.isEmpty()) {
final Element eItems = new Element("items", getFeedNamespace());
final Element eSeq = new Element("Seq", getRDFNamespace());
for (final Item item : items) {
final Element lis = new Element("li", getRDFNamespace());
final String uri = item.getUri();
if (uri != null) {
lis.setAttribute("resource", uri, getRDFNamespace());
}
eSeq.addContent(lis);
}
eItems.addContent(eSeq);
eChannel.addContent(eItems);
}
}
开发者ID:rometools,项目名称:rome,代码行数:27,代码来源:RSS10Generator.java
示例9: populateChannel
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
@Override
protected void populateChannel(final Channel channel, final Element eChannel) {
super.populateChannel(channel, eChannel);
final String generator = channel.getGenerator();
if (generator != null) {
eChannel.addContent(generateSimpleElement("generator", generator));
}
final int ttl = channel.getTtl();
if (ttl > -1) {
eChannel.addContent(generateSimpleElement("ttl", String.valueOf(ttl)));
}
final List<Category> categories = channel.getCategories();
for (final Category category : categories) {
eChannel.addContent(generateCategoryElement(category));
}
generateForeignMarkup(eChannel, channel.getForeignMarkup());
}
开发者ID:rometools,项目名称:rome,代码行数:24,代码来源:RSS20Generator.java
示例10: newFeed
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
@Override
protected Channel newFeed() {
Channel channel = new Channel("rss_2.0");
channel.setLink(applicationSettings.getBaseUrl() + "/posts/feed/");
channel.setTitle(applicationSettings.getRssChannelTitle());
channel.setDescription(applicationSettings.getRssChannelDescription());
postService.getOneMostRecent()
.ifPresent(p -> channel.setPubDate(Date.from(p.getPostDate().toInstant())));
return channel;
}
开发者ID:mintster,项目名称:nixmash-blog,代码行数:11,代码来源:RssPostFeedView.java
示例11: buildFeedMetadata
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
@Override
protected void buildFeedMetadata(Map<String, Object> model, Channel feed,
HttpServletRequest request) {
feed.setTitle("HRMS News Feeds");
feed.setDescription("Packt Publishing's Spring MVC Blueprint");
feed.setLink("https://www.packtpub.com/");
super.buildFeedMetadata(model, feed, request);
}
开发者ID:PacktPublishing,项目名称:Spring-MVC-Blueprints,代码行数:11,代码来源:HrmsRssViewBuilder.java
示例12: buildFeedEntries
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
/**
* Invokes {@link #buildFeedItems(Map, HttpServletRequest, HttpServletResponse)}
* to get a list of feed items.
*/
@Override
protected final void buildFeedEntries(Map<String, Object> model, Channel channel,
HttpServletRequest request, HttpServletResponse response) throws Exception {
List<Item> items = buildFeedItems(model, request, response);
channel.setItems(items);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:AbstractRssFeedView.java
示例13: write
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
@Test
public void write() throws IOException, SAXException {
Channel channel = new Channel("rss_2.0");
channel.setTitle("title");
channel.setLink("http://example.com");
channel.setDescription("description");
Item item1 = new Item();
item1.setTitle("title1");
Item item2 = new Item();
item2.setTitle("title2");
List<Item> items = new ArrayList<Item>(2);
items.add(item1);
items.add(item2);
channel.setItems(items);
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
converter.write(channel, null, outputMessage);
assertEquals("Invalid content-type", new MediaType("application", "rss+xml", utf8),
outputMessage.getHeaders().getContentType());
String expected = "<rss version=\"2.0\">" +
"<channel><title>title</title><link>http://example.com</link><description>description</description>" +
"<item><title>title1</title></item>" +
"<item><title>title2</title></item>" +
"</channel></rss>";
assertXMLEqual(expected, outputMessage.getBodyAsString(utf8));
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:31,代码来源:RssChannelHttpMessageConverterTests.java
示例14: newFeed
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
/**
* Create a new Channel instance to hold the entries.
* <p>By default returns an RSS 2.0 channel, but the subclass can specify any channel.
*/
@Override protected Channel newFeed() {
Channel channel = new Channel("rss_2.0");
channel.setLink(String.format("%s/%s", jakdukProperties.getWebServerUrl(), "/rss"));
channel.setTitle(JakdukUtils.getMessageSource("common.jakduk"));
channel.setDescription(JakdukUtils.getMessageSource("common.jakduk.rss.description"));
return channel;
}
开发者ID:JakduK,项目名称:jakduk-api,代码行数:13,代码来源:DocumentRssFeedView.java
示例15: copyInto
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
@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()));
}
}
开发者ID:rometools,项目名称:rome,代码行数:31,代码来源:ConverterForRSS090.java
示例16: createRealFeed
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
protected WireFeed createRealFeed(final String type, final SyndFeed syndFeed) {
final Channel channel = new Channel(type);
channel.setModules(ModuleUtils.cloneModules(syndFeed.getModules()));
channel.setStyleSheet(syndFeed.getStyleSheet());
channel.setEncoding(syndFeed.getEncoding());
channel.setTitle(syndFeed.getTitle());
final String link = syndFeed.getLink();
final List<SyndLink> links = syndFeed.getLinks();
if (link != null) {
channel.setLink(link);
} else if (!links.isEmpty()) {
channel.setLink(links.get(0).getHref());
}
channel.setDescription(syndFeed.getDescription());
final SyndImage sImage = syndFeed.getImage();
if (sImage != null) {
channel.setImage(createRSSImage(sImage));
}
final List<SyndEntry> sEntries = syndFeed.getEntries();
if (sEntries != null) {
channel.setItems(createRSSItems(sEntries));
}
final List<Element> foreignMarkup = syndFeed.getForeignMarkup();
if (!foreignMarkup.isEmpty()) {
channel.setForeignMarkup(foreignMarkup);
}
return channel;
}
开发者ID:rometools,项目名称:rome,代码行数:35,代码来源:ConverterForRSS090.java
示例17: createRealFeed
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
@Override
protected WireFeed createRealFeed(final String type, final SyndFeed syndFeed) {
final Channel channel = (Channel) super.createRealFeed(type, syndFeed);
final List<SyndCategory> cats = syndFeed.getCategories(); // c
if (!cats.isEmpty()) {
channel.setCategories(createRSSCategories(cats));
}
return channel;
}
开发者ID:rometools,项目名称:rome,代码行数:10,代码来源:ConverterForRSS094.java
示例18: parseChannel
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
@Override
protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {
final Channel channel = (Channel) super.parseChannel(rssRoot, locale);
final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());
final String uri = eChannel.getAttributeValue("about", getRDFNamespace());
if (uri != null) {
channel.setUri(uri);
}
return channel;
}
开发者ID:rometools,项目名称:rome,代码行数:14,代码来源:RSS10Parser.java
示例19: generate
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
@Override
public Document generate(final WireFeed feed) throws FeedException {
final Channel channel = (Channel) feed;
final Element root = createRootElement(channel);
populateFeed(channel, root);
purgeUnusedNamespaceDeclarations(root);
return createDocument(root);
}
开发者ID:rometools,项目名称:rome,代码行数:9,代码来源:RSS090Generator.java
示例20: createRootElement
import com.rometools.rome.feed.rss.Channel; //导入依赖的package包/类
protected Element createRootElement(final Channel channel) {
final Element root = new Element("RDF", getRDFNamespace());
root.addNamespaceDeclaration(getFeedNamespace());
root.addNamespaceDeclaration(getRDFNamespace());
root.addNamespaceDeclaration(getContentNamespace());
generateModuleNamespaceDefs(root);
return root;
}
开发者ID:rometools,项目名称:rome,代码行数:9,代码来源:RSS090Generator.java
注:本文中的com.rometools.rome.feed.rss.Channel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论