当前位置: 首页>>代码示例>>Java>>正文


Java SyndEntry.setUpdatedDate方法代码示例

本文整理汇总了Java中com.sun.syndication.feed.synd.SyndEntry.setUpdatedDate方法的典型用法代码示例。如果您正苦于以下问题:Java SyndEntry.setUpdatedDate方法的具体用法?Java SyndEntry.setUpdatedDate怎么用?Java SyndEntry.setUpdatedDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.syndication.feed.synd.SyndEntry的用法示例。


在下文中一共展示了SyndEntry.setUpdatedDate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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();
}
 
开发者ID:jsmadja,项目名称:shmuphiscores,代码行数:32,代码来源:Timeline.java

示例2: createRssEntry

import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
/**
 * Creates the feeds entry.
 *
 * @param item
 *            The note.
 * @param locale
 *            The locale.
 * @param dateFormatter
 *            The date formatter.
 * @return The entry as {@link SyndEntry}.
 */
private SyndEntry createRssEntry(final NoteData item, Locale locale, DateFormat dateFormatter) {
    SyndEntry entry = new SyndEntryImpl();
    String noHtmlTitle = StringEscapeHelper.getSingleLineTextFromXML(item.getContent());
    int endIndex = Math.min(noHtmlTitle.length(), 100);
    String title = item.getBlog().getTitle() + ": " + noHtmlTitle.substring(0, endIndex);
    if (title.length() < noHtmlTitle.length()) {
        title += "...";
    }
    if (item.isDirect()) {
        title = messages.getText("rss.item.direct.message.prefix", locale) + " " + title;
    }
    entry.setTitle(title);
    entry.setLink(ServiceLocator.instance().getService(PermalinkGenerationManagement.class)
            .getNoteLink(item.getBlog().getAlias(), item.getId(), true));
    entry.setPublishedDate(item.getCreationDate());
    entry.setUpdatedDate(item.getLastModificationDate());
    String author = UserNameHelper.getCompleteSignature(item.getUser(), " ", item.getUser()
            .getAlias());
    entry.setAuthor(author);

    ArrayList<SyndCategory> categories = new ArrayList<SyndCategory>();
    for (TagData tag : item.getTags()) {
        SyndCategoryImpl category = new SyndCategoryImpl();
        category.setName(tag.getName());
        category.setTaxonomyUri(ServiceLocator.instance()
                .getService(PermalinkGenerationManagement.class)
                .getTagLink(tag.getName(), true));
        categories.add(category);
    }
    entry.setCategories(categories);
    SyndContent description = new SyndContentImpl();
    description.setType("text/html");
    StringBuilder content = new StringBuilder();
    content.append(messages.getText("newsfeed.microblog.content.metadata.author", locale));
    content.append(author);
    content.append(messages.getText(
            "newsfeed.microblog.content.metadata.author.date.separator", locale));
    content.append(dateFormatter.format(item.getCreationDate()));
    content.append(messages.getText(
            "newsfeed.microblog.content.metadata.date.content.separator", locale));
    content.append(item.getContent());

    if (CollectionUtils.isNotEmpty(item.getAttachments())) {
        content.append(messages.getText("rss.item.attachment.list", locale) + " ");
        for (AttachmentData attachment : item.getAttachments()) {
            content.append("<a href=\"");
            content.append(AttachmentHelper.determineAbsoluteAttachmentUrl(attachment, true));
            content.append("\">");
            content.append(attachment.getFileName());
            content.append("</a> ");
        }
    }
    description.setValue(content.toString());
    entry.setDescription(description);
    return entry;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:68,代码来源:RssNoteWriter.java

示例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("&nbsp;", " "); // 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);
   }
 
开发者ID:huihoo,项目名称:olat,代码行数:69,代码来源:RSSFeed.java

示例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("&nbsp;", " "); // 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);
}
 
开发者ID:huihoo,项目名称:olat,代码行数:69,代码来源:RSSFeed.java


注:本文中的com.sun.syndication.feed.synd.SyndEntry.setUpdatedDate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。