本文整理汇总了Java中com.sun.syndication.feed.synd.SyndEntry.setEnclosures方法的典型用法代码示例。如果您正苦于以下问题:Java SyndEntry.setEnclosures方法的具体用法?Java SyndEntry.setEnclosures怎么用?Java SyndEntry.setEnclosures使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.syndication.feed.synd.SyndEntry
的用法示例。
在下文中一共展示了SyndEntry.setEnclosures方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSyndEntry
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
@Override
protected SyndEntry createSyndEntry(Item item, boolean preserveWireItem) {
SyndEntry syndEntry = super.createSyndEntry(item, preserveWireItem);
List cats = item.getCategories();
if (cats.size()>0) {
Set s = new LinkedHashSet(); // using a set to remove duplicates and use a LinkedHashSet to try to retain the document order
s.addAll(createSyndCategories(cats)); // feed native categories (as syndcat)
s.addAll(syndEntry.getCategories()); // DC subjects (as syndcat)
syndEntry.setCategories(new ArrayList(s)); //c
}
List enclosures = item.getEnclosures();
if (enclosures.size()>0) {
syndEntry.setEnclosures(createSyndEnclosures(enclosures));
}
return syndEntry;
}
示例2: rss
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
public String rss() throws IOException, FeedException {
SyndFeed feed = new SyndFeedImpl();
feed.setTitle("hiscores.shmup.com");
feed.setFeedType("rss_2.0");
feed.setDescription("hiscores.shmup.com");
feed.setLink("http://hiscores.shmup.com");
List entries = new ArrayList();
feed.setEntries(entries);
for (Score score : scores) {
SyndEntry entry = new SyndEntryImpl();
entry.setTitle(score.getGameTitle());
entry.setAuthor(score.player.name);
entry.setLink("http://hiscores.shmup.com/score/" + score.id);
SyndContentImpl content = new SyndContentImpl();
content.setValue(score.tweet());
entry.setDescription(content);
entry.setPublishedDate(score.getCreatedAt());
entry.setUpdatedDate(score.getCreatedAt());
SyndEnclosureImpl enclosure = new SyndEnclosureImpl();
enclosure.setUrl(score.game.cover);
enclosure.setType(score.game.getCoverType());
entry.setEnclosures(Lists.newArrayList(enclosure));
entries.add(entry);
}
Writer writer = new StringWriter();
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, writer);
writer.close();
Controller.response().setContentType("application/rss+xml");
return writer.toString();
}
示例3: RSSFeed
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
/**
* Constructor. The identityKey is needed to generate personal URLs for the corresponding user.
*/
protected RSSFeed(final Feed feed, final Identity identity, final Long courseId, final String nodeId,final Translator translator, RepositoryService repositoryService) {
super();
// This helper object is required for generating the appropriate URLs for
// the given user (identity)
final FeedViewHelper helper = new FeedViewHelper(feed, identity, courseId, nodeId, translator, repositoryService);
setFeedType("rss_2.0");
setEncoding(RSSServlet.DEFAULT_ENCODING);
setTitle(feed.getTitle());
// According to the rss specification, the feed channel description is not
// (explicitly) allowed to contain html tags.
String strippedDescription = FilterFactory.getHtmlTagsFilter().filter(feed.getDescription());
strippedDescription = strippedDescription.replaceAll(" ", " "); // TODO: remove when filter
// does it
setDescription(strippedDescription);
setLink(helper.getJumpInLink());
setPublishedDate(feed.getLastModified());
// The image
if (feed.getImageName() != null) {
final SyndImage image = new SyndImageImpl();
image.setDescription(feed.getDescription());
image.setTitle(feed.getTitle());
image.setLink(getLink());
image.setUrl(helper.getImageUrl());
setImage(image);
}
final List<SyndEntry> episodes = new ArrayList<SyndEntry>();
for (final Item item : feed.getPublishedItems()) {
final SyndEntry entry = new SyndEntryImpl();
entry.setTitle(item.getTitle());
final SyndContent itemDescription = new SyndContentImpl();
itemDescription.setType("text/plain");
itemDescription.setValue(helper.getItemDescriptionForBrowser(item));
entry.setDescription(itemDescription);
// Link will also be converted to the rss guid tag. Except if there's an
// enclosure, then the enclosure url is used.
// Use jump-in link far all entries. This will be overriden if the item
// has an enclosure.
entry.setLink(helper.getJumpInLink() + "#" + item.getGuid());
entry.setPublishedDate(item.getPublishDate());
entry.setUpdatedDate(item.getLastModified());
// The enclosure is the media (audio or video) file of the episode
final Enclosure media = item.getEnclosure();
if (media != null) {
final SyndEnclosure enclosure = new SyndEnclosureImpl();
enclosure.setUrl(helper.getMediaUrl(item));
enclosure.setType(media.getType());
enclosure.setLength(media.getLength());
// Also set the item link to point to the enclosure
entry.setLink(helper.getMediaUrl(item));
final List<SyndEnclosure> enclosures = new ArrayList<SyndEnclosure>();
enclosures.add(enclosure);
entry.setEnclosures(enclosures);
}
episodes.add(entry);
}
setEntries(episodes);
}
示例4: RSSFeed
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
/**
* Constructor. The identityKey is needed to generate personal URLs for the corresponding user.
*/
protected RSSFeed(final Feed feed, final Identity identity, final Long courseId, final String nodeId, final Translator translator, RepositoryService repositoryService) {
super();
// This helper object is required for generating the appropriate URLs for
// the given user (identity)
final FeedViewHelper helper = new FeedViewHelper(feed, identity, courseId, nodeId, translator, repositoryService);
setFeedType("rss_2.0");
setEncoding(DEFAULT_ENCODING);
setTitle(feed.getTitle());
// According to the rss specification, the feed channel description is not
// (explicitly) allowed to contain html tags.
String strippedDescription = FilterFactory.getHtmlTagsFilter().filter(feed.getDescription());
strippedDescription = strippedDescription.replaceAll(" ", " "); // TODO: remove when filter
// does it
setDescription(strippedDescription);
setLink(helper.getJumpInLink());
setPublishedDate(feed.getLastModified());
// The image
if (feed.getImageName() != null) {
final SyndImage image = new SyndImageImpl();
image.setDescription(feed.getDescription());
image.setTitle(feed.getTitle());
image.setLink(getLink());
image.setUrl(helper.getImageUrl());
setImage(image);
}
final List<SyndEntry> episodes = new ArrayList<SyndEntry>();
for (final Item item : feed.getPublishedItems()) {
final SyndEntry entry = new SyndEntryImpl();
entry.setTitle(item.getTitle());
final SyndContent itemDescription = new SyndContentImpl();
itemDescription.setType("text/plain");
itemDescription.setValue(helper.getItemDescriptionForBrowser(item));
entry.setDescription(itemDescription);
// Link will also be converted to the rss guid tag. Except if there's an
// enclosure, then the enclosure url is used.
// Use jump-in link far all entries. This will be overriden if the item
// has an enclosure.
entry.setLink(helper.getJumpInLink() + "#" + item.getGuid());
entry.setPublishedDate(item.getPublishDate());
entry.setUpdatedDate(item.getLastModified());
// The enclosure is the media (audio or video) file of the episode
final Enclosure media = item.getEnclosure();
if (media != null) {
final SyndEnclosure enclosure = new SyndEnclosureImpl();
enclosure.setUrl(helper.getMediaUrl(item));
enclosure.setType(media.getType());
enclosure.setLength(media.getLength());
// Also set the item link to point to the enclosure
entry.setLink(helper.getMediaUrl(item));
final List<SyndEnclosure> enclosures = new ArrayList<SyndEnclosure>();
enclosures.add(enclosure);
entry.setEnclosures(enclosures);
}
episodes.add(entry);
}
setEntries(episodes);
}