本文整理汇总了Java中com.rometools.rome.feed.rss.Item.setTitle方法的典型用法代码示例。如果您正苦于以下问题:Java Item.setTitle方法的具体用法?Java Item.setTitle怎么用?Java Item.setTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rometools.rome.feed.rss.Item
的用法示例。
在下文中一共展示了Item.setTitle方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildFeedItems
import com.rometools.rome.feed.rss.Item; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected List<Item> buildFeedItems(Map<String, Object> model,
HttpServletRequest req, HttpServletResponse resp) throws Exception {
// get data model which is passed by the Spring container
List<HrmsNews> news = (List<HrmsNews>) model.get("allNews");
List<Item> items = new ArrayList<Item>(news.size());
for(HrmsNews topic : news ){
Item item = new Item();
Content content = new Content();
content.setValue(topic.getSummary());
item.setContent(content);
item.setTitle(topic.getDescription());
item.setLink(topic.getLink());
item.setPubDate(new Date());
items.add(item);
}
return items;
}
示例2: writeOtherCharset
import com.rometools.rome.feed.rss.Item; //导入方法依赖的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());
}
示例3: buildFeedItems
import com.rometools.rome.feed.rss.Item; //导入方法依赖的package包/类
protected List buildFeedItems(Map model, HttpServletRequest request, HttpServletResponse response)
throws Exception {
List<Podcast> podcasts = (List<Podcast>) model.get("list_of_podcasts");
List<Item> items = new ArrayList<Item>(podcasts.size());
for (Podcast podcast : podcasts) {
Item item = new Item();
// String date = String.format("%1$tY-%1$tm-%1$td", podcast.getLastEpisode().getPublicationDate());
item.setTitle(podcast.getTitle());
item.setPubDate(podcast.getPublicationDate());
item.setLink(model.get("HOST_AND_PORT_URL") + "/podcasts/" + podcast.getPodcastId()
+ "/" + podcast.getTitleInUrl());
Description podcastDescription = new Description();
podcastDescription.setValue(podcast.getDescription());
item.setDescription(podcastDescription);
items.add(item);
}
return items;
}
示例4: createItem
import com.rometools.rome.feed.rss.Item; //导入方法依赖的package包/类
private Item createItem(Post post) {
Item item = new Item();
item.setLink(applicationSettings.getBaseUrl() + "/post/" + post.getPostName());
item.setTitle(post.getPostTitle());
item.setDescription(createDescription(post));
item.setPubDate(getPostDate(post));
return item;
}
示例5: buildFeedItems
import com.rometools.rome.feed.rss.Item; //导入方法依赖的package包/类
@Override
protected List<Item> buildFeedItems(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
List<Item> items = new ArrayList<Item>();
for (String name : model.keySet()) {
Item item = new Item();
item.setTitle(name);
Description description = new Description();
description.setValue((String) model.get(name));
item.setDescription(description);
items.add(item);
}
return items;
}
示例6: write
import com.rometools.rome.feed.rss.Item; //导入方法依赖的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));
}
示例7: convertArticle
import com.rometools.rome.feed.rss.Item; //导入方法依赖的package包/类
private Item convertArticle(Article article) {
Item entry = new Item();
Guid guid = new Guid();
guid.setValue(article.getArticleId().toString());
entry.setGuid(guid);
entry.setTitle(cleanXml10Characters(article.getTitle()));
entry.setPubDate(Date.from(article.getCreateTime()));
Description summary = new Description();
summary.setType("html");
summary.setValue(buildSummary(article));
entry.setDescription(summary);
entry.setLink(articleUrl(article));
return entry;
}
示例8: buildFeedItems
import com.rometools.rome.feed.rss.Item; //导入方法依赖的package包/类
protected List buildFeedItems(Map model, HttpServletRequest request, HttpServletResponse response)
throws Exception {
List<Episode> episodes = (List<Episode>) model.get("list_of_episodes");
List<Item> items = new ArrayList<Item>(episodes.size());
for (Episode episode : episodes) {
Item item = new Item();
String date = String.format("%1$tY-%1$tm-%1$td", episode.getPublicationDate());
item.setTitle(episode.getTitle());
item.setPubDate(episode.getPublicationDate());
item.setLink(model.get("HOST_AND_PORT_URL") + "/podcasts/" + episode.getPodcastId()
+ "/" + episode.getPodcast().getTitleInUrl()+ "/episodes/" + episode.getEpisodeId()
+ "/" + episode.getTitleInUrl());
Description episodeDescription = new Description();
episodeDescription.setValue(episode.getDescription());
item.setDescription(episodeDescription);
//set enclosures
List<Enclosure> enclosures = new ArrayList<Enclosure>();
Enclosure enclosure = new Enclosure();
enclosure.setUrl(episode.getMediaUrl());
if(episode.getLength() != null) enclosure.setLength(episode.getLength());
if(episode.getEnclosureType() != null ) enclosure.setType(episode.getEnclosureType());
enclosures.add(enclosure);
item.setEnclosures(enclosures);
items.add(item);
}
return items;
}
示例9: buildFeedItems
import com.rometools.rome.feed.rss.Item; //导入方法依赖的package包/类
protected List buildFeedItems(Map model, HttpServletRequest request, HttpServletResponse response)
throws Exception {
List<Podcast> podcasts = (List<Podcast>) model.get("list_of_podcasts");
List<Item> items = new ArrayList<Item>(podcasts.size());
for (Podcast podcast : podcasts) {
Episode episode = podcast.getLastEpisode();
Item item = new Item();
String date = String.format("%1$tY-%1$tm-%1$td", episode.getPublicationDate());
item.setTitle(podcast.getTitle()+ " - " + episode.getTitle());
item.setPubDate(podcast.getPublicationDate());
item.setLink( model.get("HOST_AND_PORT_URL") + "/podcasts/" + podcast.getPodcastId()
+ "/" + podcast.getTitleInUrl() );
Description episodeDescription = new Description();
episodeDescription.setValue(episode.getDescription());
item.setDescription(episodeDescription);
//set enclosures
List<Enclosure> enclosures = new ArrayList<Enclosure>();
Enclosure enclosure = new Enclosure();
enclosure.setUrl(episode.getMediaUrl());
if(episode.getLength() != null) enclosure.setLength(episode.getLength());
if(episode.getEnclosureType() != null ) enclosure.setType(episode.getEnclosureType());
enclosures.add(enclosure);
item.setEnclosures(enclosures);
items.add(item);
}
return items;
}
示例10: parseItem
import com.rometools.rome.feed.rss.Item; //导入方法依赖的package包/类
/**
* Parses an item element of an RSS document looking for item information.
* <p/>
* It reads title and link out of the 'item' element.
* <p/>
*
* @param rssRoot the root element of the RSS document in case it's needed for context.
* @param eItem the item element to parse.
* @return the parsed RSSItem bean.
*/
protected Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) {
final Item item = new Item();
final Element title = eItem.getChild("title", getRSSNamespace());
if (title != null) {
item.setTitle(title.getText());
}
final Element link = eItem.getChild("link", getRSSNamespace());
if (link != null) {
item.setLink(link.getText());
item.setUri(link.getText());
}
item.setModules(parseItemModules(eItem, locale));
final List<Element> foreignMarkup = extractForeignMarkup(eItem, item, getRSSNamespace());
// content:encoded elements are treated special, without a module, they have to be removed
// from the foreign markup to avoid duplication in case of read/write. Note that this fix
// will break if a content module is used
final Iterator<Element> iterator = foreignMarkup.iterator();
while (iterator.hasNext()) {
final Element element = iterator.next();
final Namespace eNamespace = element.getNamespace();
final String eName = element.getName();
if (getContentNamespace().equals(eNamespace) && eName.equals("encoded")) {
iterator.remove();
}
}
if (!foreignMarkup.isEmpty()) {
item.setForeignMarkup(foreignMarkup);
}
return item;
}
示例11: createRSSItem
import com.rometools.rome.feed.rss.Item; //导入方法依赖的package包/类
protected Item createRSSItem(final SyndEntry sEntry) {
final Item item = new Item();
item.setModules(ModuleUtils.cloneModules(sEntry.getModules()));
item.setTitle(sEntry.getTitle());
item.setLink(sEntry.getLink());
final List<Element> foreignMarkup = sEntry.getForeignMarkup();
if (!foreignMarkup.isEmpty()) {
item.setForeignMarkup(foreignMarkup);
}
item.setSource(createSource(sEntry.getSource()));
final String uri = sEntry.getUri();
if (uri != null) {
item.setUri(uri);
}
return item;
}