本文整理汇总了Java中com.rometools.rome.feed.rss.Item类的典型用法代码示例。如果您正苦于以下问题:Java Item类的具体用法?Java Item怎么用?Java Item使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Item类属于com.rometools.rome.feed.rss包,在下文中一共展示了Item类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: read
import com.rometools.rome.feed.rss.Item; //导入依赖的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());
}
示例3: 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());
}
示例4: buildFeedItems
import com.rometools.rome.feed.rss.Item; //导入依赖的package包/类
@Override
protected List<Item> buildFeedItems(final Map<String, Object> model, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
final Page<Post> posts = (Page<Post>) model.get("posts");
return posts.map(post -> {
final Item rv = new Item();
final Content content = new Content();
content.setType(Content.HTML);
content.setValue(post.getContent());
final String link = getAbsoluteUrl(request, String.format("%s/%s", permalinkDateFormatter.format(post.getPublishedOn()), post.getSlug()));
rv.setAuthor("euregjug.eu");
rv.setContent(content);
rv.setGuid(new SyndicationGuid().withPermaLink(true).withValue(link).getGuid());
rv.setLink(link);
rv.setPubDate(Date.from(post.getPublishedOn().atStartOfDay(UTC).toInstant()));
rv.setTitle(post.getTitle());
return rv;
}).getContent();
}
示例5: 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;
}
示例6: createSyndEntry
import com.rometools.rome.feed.rss.Item; //导入依赖的package包/类
protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {
final SyndEntryImpl syndEntry = new SyndEntryImpl();
if (preserveWireItem) {
syndEntry.setWireEntry(item);
}
syndEntry.setModules(ModuleUtils.cloneModules(item.getModules()));
final List<Element> foreignMarkup = item.getForeignMarkup();
if (!foreignMarkup.isEmpty()) {
syndEntry.setForeignMarkup(foreignMarkup);
}
syndEntry.setUri(item.getUri());
syndEntry.setLink(item.getLink());
syndEntry.setTitle(item.getTitle());
syndEntry.setLink(item.getLink());
syndEntry.setSource(createSource(item.getSource()));
return syndEntry;
}
示例7: createRSSItem
import com.rometools.rome.feed.rss.Item; //导入依赖的package包/类
@Override
protected Item createRSSItem(final SyndEntry sEntry) {
final Item item = super.createRSSItem(sEntry);
final SyndContent desc = sEntry.getDescription();
if (desc != null) {
item.setDescription(createItemDescription(desc));
}
final List<SyndContent> contents = sEntry.getContents();
if (Lists.isNotEmpty(contents)) {
item.setContent(createItemContent(contents.get(0)));
}
final String uri = sEntry.getUri();
if (uri != null) {
item.setUri(uri);
}
return item;
}
示例8: createRSSItem
import com.rometools.rome.feed.rss.Item; //导入依赖的package包/类
@Override
protected Item createRSSItem(final SyndEntry sEntry) {
final Item item = super.createRSSItem(sEntry);
item.setComments(sEntry.getComments());
final SyndContent sContent = sEntry.getDescription();
if (sContent != null) {
item.setDescription(createItemDescription(sContent));
}
final List<SyndContent> contents = sEntry.getContents();
if (Lists.isNotEmpty(contents)) {
final SyndContent syndContent = contents.get(0);
final Content cont = new Content();
cont.setValue(syndContent.getValue());
cont.setType(syndContent.getType());
item.setContent(cont);
}
return item;
}
示例9: createRSSItem
import com.rometools.rome.feed.rss.Item; //导入依赖的package包/类
@Override
protected Item createRSSItem(final SyndEntry sEntry) {
final Item item = super.createRSSItem(sEntry);
final List<SyndCategory> sCats = sEntry.getCategories(); // c
if (!sCats.isEmpty()) {
item.setCategories(createRSSCategories(sCats));
}
final List<SyndEnclosure> sEnclosures = sEntry.getEnclosures();
if (!sEnclosures.isEmpty()) {
item.setEnclosures(createEnclosures(sEnclosures));
}
return item;
}
示例10: parseItem
import com.rometools.rome.feed.rss.Item; //导入依赖的package包/类
/**
* Parses an item element of an RSS document looking for item information.
* <p/>
* It first invokes super.parseItem and then parses and injects the description property if
* present.
* <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.
*/
@Override
protected Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) {
final Item item = super.parseItem(rssRoot, eItem, locale);
final Element description = eItem.getChild("description", getRSSNamespace());
if (description != null) {
item.setDescription(parseItemDescription(rssRoot, description));
}
final Element encoded = eItem.getChild("encoded", getContentNamespace());
if (encoded != null) {
final Content content = new Content();
content.setType(Content.HTML);
content.setValue(encoded.getText());
item.setContent(content);
}
final String about = eItem.getAttributeValue("about", getRDFNamespace());
if (about != null) {
item.setUri(about);
}
return item;
}
示例11: parseItem
import com.rometools.rome.feed.rss.Item; //导入依赖的package包/类
/**
* Parses an item element of an RSS document looking for item information.
* <p/>
* It first invokes super.parseItem and then parses and injects the description property if
* present.
* <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.
*/
@Override
protected Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) {
final Item item = super.parseItem(rssRoot, eItem, locale);
final Element description = eItem.getChild("description", getRSSNamespace());
if (description != null) {
item.setDescription(parseItemDescription(rssRoot, description));
}
final Element encoded = eItem.getChild("encoded", getContentNamespace());
if (encoded != null) {
final Content content = new Content();
content.setType(Content.HTML);
content.setValue(encoded.getText());
item.setContent(content);
}
return item;
}
示例12: parseItem
import com.rometools.rome.feed.rss.Item; //导入依赖的package包/类
@Override
protected Item parseItem(final Element rssRoot, final Element eItem, final Locale locale) {
final Item item = super.parseItem(rssRoot, eItem, locale);
final Element pubDate = eItem.getChild("pubDate", getRSSNamespace());
if (pubDate != null) {
item.setPubDate(DateParser.parseDate(pubDate.getText(), locale));
}
final Element expirationDate = eItem.getChild("expirationDate", getRSSNamespace());
if (expirationDate != null) {
item.setExpirationDate(DateParser.parseDate(expirationDate.getText(), locale));
}
final Element description = eItem.getChild("description", getRSSNamespace());
if (description != null) {
final String type = description.getAttributeValue("type");
if (type != null) {
item.getDescription().setType(type);
}
}
return item;
}
示例13: populateChannel
import com.rometools.rome.feed.rss.Item; //导入依赖的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);
}
}
示例14: populateItem
import com.rometools.rome.feed.rss.Item; //导入依赖的package包/类
@Override
protected void populateItem(final Item item, final Element eItem, final int index) {
super.populateItem(item, eItem, index);
final String link = item.getLink();
final String uri = item.getUri();
if (uri != null) {
eItem.setAttribute("about", uri, getRDFNamespace());
} else if (link != null) {
eItem.setAttribute("about", link, getRDFNamespace());
}
final Description description = item.getDescription();
if (description != null) {
eItem.addContent(generateSimpleElement("description", description.getValue()));
}
if (item.getModule(getContentNamespace().getURI()) == null && item.getContent() != null) {
final Element elem = new Element("encoded", getContentNamespace());
elem.addContent(item.getContent().getValue());
eItem.addContent(elem);
}
}
示例15: populateItem
import com.rometools.rome.feed.rss.Item; //导入依赖的package包/类
@Override
protected void populateItem(final Item item, final Element eItem, final int index) {
super.populateItem(item, eItem, index);
final Description description = item.getDescription();
if (description != null) {
eItem.addContent(generateSimpleElement("description", description.getValue()));
}
final Namespace contentNamespace = getContentNamespace();
final Content content = item.getContent();
if (item.getModule(contentNamespace.getURI()) == null && content != null) {
final Element elem = new Element("encoded", contentNamespace);
elem.addContent(content.getValue());
eItem.addContent(elem);
}
}