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


Java SyndEnclosure类代码示例

本文整理汇总了Java中com.sun.syndication.feed.synd.SyndEnclosure的典型用法代码示例。如果您正苦于以下问题:Java SyndEnclosure类的具体用法?Java SyndEnclosure怎么用?Java SyndEnclosure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SyndEnclosure类属于com.sun.syndication.feed.synd包,在下文中一共展示了SyndEnclosure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEnclosures

import com.sun.syndication.feed.synd.SyndEnclosure; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List getEnclosures() {
    List<SyndEnclosure> enc = super.getEnclosures();
    List<SyndEnclosure> result = new ArrayList<SyndEnclosure>(enc.size());
    for (SyndEnclosure e : enc) {
        SyndEnclosureImpl ee = new SyndEnclosureImpl();
        if (e != null) {
            ee.setLength(e.getLength());
            ee.setType(removeInvalidChars(e.getType()));
            ee.setUrl(removeInvalidChars(e.getUrl()));
        }
        result.add(ee);
    }
    return result;
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:17,代码来源:ExtendedSyndEntryImpl.java

示例2: _testEntry

import com.sun.syndication.feed.synd.SyndEnclosure; //导入依赖的package包/类
protected void _testEntry(int i) throws Exception {
    List items = getCachedSyndFeed().getEntries();
    SyndEntry entry = (SyndEntry) items.get(i);

    assertProperty(entry.getTitle(),"feed.entry["+i+"].title");
    assertProperty(entry.getTitleEx().getValue(),"feed.entry["+i+"].title");
    assertEquals("text",entry.getTitleEx().getType());
    
    assertEquals(entry.getLink(),"http://example.com/blog/entry" + (i + 1));
    assertEquals(((SyndEnclosure)entry.getEnclosures().get(0)).getUrl(),"http://example.com/blog/enclosure"+(i+1)+".gif");
    assertProperty(entry.getAuthor(),"feed.entry["+i+"].author.name");
    Date d = DateParser.parseW3CDateTime("2000-0"+(i+1)+"-01T01:00:00Z");
    assertEquals(entry.getPublishedDate(),d);
    assertProperty(entry.getDescription().getValue(),"feed.entry["+i+"].summary");
    assertProperty(((SyndContent)entry.getContents().get(0)).getValue(),"feed.entry["+i+"].content[0]");
    assertEquals(1, ((List)entry.getForeignMarkup()).size());
    SyndLink slink = (SyndLink)entry.getLinks().get(2);
    assertTrue(slink.getHref().startsWith("tag:"));
}
 
开发者ID:Norkart,项目名称:NK-VirtualGlobe,代码行数:20,代码来源:TestSyndFeedAtom10.java

示例3: _testEnclosures

import com.sun.syndication.feed.synd.SyndEnclosure; //导入依赖的package包/类
protected void _testEnclosures(List encs,String prefix) throws Exception {
    Set s1 = new HashSet();
    Set s2 = new HashSet();
    for (int i=0;i<encs.size();i++) {
        SyndEnclosure enc = (SyndEnclosure) encs.get(i);
        s1.add(enc.getUrl()+" "+enc.getType()+" "+enc.getLength());
        s2.add(getPrefix() + "." +prefix+".enclousure["+i+"]^url"+" "+
               getPrefix() + "." +prefix+".enclousure["+i+"]^type"+" "+
               "100");
    }
    assertTrue(s1.equals(s2));
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:13,代码来源:TestSyndFeedRSS092.java

示例4: createSyndEnclosure

import com.sun.syndication.feed.synd.SyndEnclosure; //导入依赖的package包/类
public SyndEnclosure createSyndEnclosure(Feed feed, Entry entry,
        Link link) {
    SyndEnclosure syndEncl = new SyndEnclosureImpl();
    syndEncl.setUrl(link.getHrefResolved());
    syndEncl.setType(link.getType());
    syndEncl.setLength(link.getLength());
    return syndEncl;
}
 
开发者ID:4thline,项目名称:feeds,代码行数:9,代码来源:ConverterForAtom10.java

示例5: createAtomEnclosure

import com.sun.syndication.feed.synd.SyndEnclosure; //导入依赖的package包/类
public Link createAtomEnclosure(SyndEnclosure syndEnclosure) {
  Link link = new Link();
  link.setRel(     "enclosure");
  link.setType(    syndEnclosure.getType());
  link.setHref(    syndEnclosure.getUrl());
  link.setLength(  syndEnclosure.getLength());
  return link;
}
 
开发者ID:4thline,项目名称:feeds,代码行数:9,代码来源:ConverterForAtom10.java

示例6: createSyndEnclosure

import com.sun.syndication.feed.synd.SyndEnclosure; //导入依赖的package包/类
public SyndEnclosure createSyndEnclosure(Entry entry, Link link) {
    SyndEnclosure syndEncl = new SyndEnclosureImpl();
    syndEncl.setUrl(link.getHrefResolved());
    syndEncl.setType(link.getType());
    syndEncl.setLength(link.getLength());
    return syndEncl;
}
 
开发者ID:4thline,项目名称:feeds,代码行数:8,代码来源:ConverterForAtom03.java

示例7: createSyndEnclosures

import com.sun.syndication.feed.synd.SyndEnclosure; //导入依赖的package包/类
protected List createSyndEnclosures(List enclosures) {
    List sEnclosures = new ArrayList();
    for (int i=0;i<enclosures.size();i++) {
        Enclosure enc = (Enclosure) enclosures.get(i);
        SyndEnclosure sEnc = new SyndEnclosureImpl();
        sEnc.setUrl(enc.getUrl());
        sEnc.setType(enc.getType());
        sEnc.setLength(enc.getLength());
        sEnclosures.add(sEnc);
    }
    return sEnclosures;
}
 
开发者ID:4thline,项目名称:feeds,代码行数:13,代码来源:ConverterForRSS092.java

示例8: createEnclosures

import com.sun.syndication.feed.synd.SyndEnclosure; //导入依赖的package包/类
protected List createEnclosures(List sEnclosures) {
    List enclosures = new ArrayList();
    for (int i=0;i<sEnclosures.size();i++) {
        SyndEnclosure sEnc = (SyndEnclosure) sEnclosures.get(i);
        Enclosure enc = new Enclosure();
        enc.setUrl(sEnc.getUrl());
        enc.setType(sEnc.getType());
        enc.setLength(sEnc.getLength());
        enclosures.add(enc);
    }
    return enclosures;
}
 
开发者ID:4thline,项目名称:feeds,代码行数:13,代码来源:ConverterForRSS092.java

示例9: createSyndEnclosure

import com.sun.syndication.feed.synd.SyndEnclosure; //导入依赖的package包/类
public SyndEnclosure createSyndEnclosure(Feed feed, Entry entry,
        Link link) {
    SyndEnclosure syndEncl = new SyndEnclosureImpl();
    syndEncl.setUrl(link.getHref());
    syndEncl.setType(link.getType());
    syndEncl.setLength(link.getLength());
    return syndEncl;
}
 
开发者ID:Norkart,项目名称:NK-VirtualGlobe,代码行数:9,代码来源:ConverterForAtom10.java

示例10: parse

import com.sun.syndication.feed.synd.SyndEnclosure; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void parse() throws Exception {
	SyndFeedInput input = new SyndFeedInput();
	byte b[] = downloadAndSendBinary(url);
	if (b != null) {
		SyndFeed feed = input.build(new XmlReader(new ByteArrayInputStream(b)));
		name = feed.getTitle();
		if (feed.getCategories() != null && feed.getCategories().size() > 0) {
			SyndCategory category = (SyndCategory) feed.getCategories().get(0);
			tempCategory = category.getName();
		}
		List<SyndEntry> entries = feed.getEntries();
		for (SyndEntry entry : entries) {
			tempItemTitle = entry.getTitle();
			tempItemLink = entry.getLink();
			tempFeedLink = entry.getUri();
			tempItemThumbURL = null;

			ArrayList<Element> elements = (ArrayList<Element>) entry.getForeignMarkup();
			for (Element elt : elements) {
				if ("group".equals(elt.getName()) && "media".equals(elt.getNamespacePrefix())) {
					List<Content> subElts = elt.getContent();
					for (Content subelt : subElts) {
						if (subelt instanceof Element) {
							parseElement((Element) subelt, false);
						}
					}
				}
				parseElement(elt, true);
			}
			List<SyndEnclosure> enclosures = entry.getEnclosures();
			for (SyndEnclosure enc : enclosures) {
				if (StringUtils.isNotBlank(enc.getUrl())) {
					tempItemLink = enc.getUrl();
				}
			}
			manageItem();
		}
	}
	setLastModified(System.currentTimeMillis());
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:42,代码来源:Feed.java

示例11: parseFeedEnclosures

import com.sun.syndication.feed.synd.SyndEnclosure; //导入依赖的package包/类
/**
 * Parses the entries contained in an RSS feed, extracts the enclosures, converts them to an {@link Attachment}
 * adds them to the map with the entry uri as key.
 * <p>The RSS spec says there is only one enclosure per item so this is what we work with. We don't actually check this so it's possible
 * that if you have more than one enclosure attached to an item that only the latest one will be presented in the end.
 *
 * @param feed
 * @return
 */
public static Map<String, Attachment> parseFeedEnclosures(SyndFeed feed) {
	
	Map<String,Attachment> attachments = new HashMap<String,Attachment>();
	
	// image mime types that are ok to be rendered as an image
	List<String> imageTypes = new ArrayList<String>();
	imageTypes.add("image/jpeg");
	imageTypes.add("image/gif");
	imageTypes.add("image/png");
	imageTypes.add("image/jpg");
	
	List<SyndEntry> entries = feed.getEntries();
	for(SyndEntry entry: entries) {
		
		//get entry uri, but it could be blank so if so, skip this item
		if(StringUtils.isBlank(entry.getUri())) {
			continue;
		}
		
		//for each enclosure attached to an entry get the first one and use that.			
		List<SyndEnclosure> enclosures = entry.getEnclosures();
		for(SyndEnclosure e: enclosures) {
			
			//convert to an Attachment
			Attachment a = new Attachment();
			a.setUrl(e.getUrl());
			a.setDisplayLength(formatLength(e.getLength()));
			a.setType(e.getType());
			
			//process the url into a displayname (get just the filename from the full URL)
			String displayName = StringUtils.substringAfterLast(e.getUrl(), "/");
			if(StringUtils.isNotBlank(displayName)){
				a.setDisplayName(displayName);
			} else {
				a.setDisplayName(Messages.getString("view.attachment.default"));
			}
			
			//check if its an iamge we are able to display as the thumbnail for the entry
			if(imageTypes.contains(e.getType())){
				a.setImage(true);
			} 
			
			attachments.put(entry.getUri(), a);
		}
	}
	
	return attachments;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:58,代码来源:FeedParser.java

示例12: convertToItem

import com.sun.syndication.feed.synd.SyndEnclosure; //导入依赖的package包/类
/**
 * Converts a <code>SyndEntry</code> into an <code>Item</code>
 * 
 * @param entry
 *            The SyndEntry
 * @return The Item
 */
private Item convertToItem(final SyndEntry entry) {
    // A SyncEntry can potentially have many attributes like title, description,
    // guid, link, enclosure or content. In OLAT, however, items are limited
    // to the attributes, title, description and one media file (called
    // enclosure in RSS) for simplicity.
    final Item e = new Item();
    e.setTitle(entry.getTitle());
    e.setDescription(entry.getDescription() != null ? entry.getDescription().getValue() : null);
    // Extract content objects from syndication item
    final StringBuffer sb = new StringBuffer();
    for (final SyndContent content : (List<SyndContent>) entry.getContents()) {
        // we don't check for type, assume it is html or txt
        if (sb.length() > 0) {
            sb.append("<p />");
        }
        sb.append(content.getValue());
    }
    // Set aggregated content from syndication item as our content
    if (sb.length() > 0) {
        e.setContent(sb.toString());
    }
    e.setGuid(entry.getUri());
    e.setExternalLink(entry.getLink());
    e.setLastModified(entry.getUpdatedDate());
    e.setPublishDate(entry.getPublishedDate());

    for (final Object enclosure : entry.getEnclosures()) {
        if (enclosure instanceof SyndEnclosure) {
            final SyndEnclosure syndEnclosure = (SyndEnclosure) enclosure;
            final Enclosure media = new Enclosure();
            media.setExternalUrl(syndEnclosure.getUrl());
            media.setType(syndEnclosure.getType());
            media.setLength(syndEnclosure.getLength());
            e.setEnclosure(media);
        }
        // Break after one cycle because only one media file is supported
        break;
    }
    return e;
}
 
开发者ID:huihoo,项目名称:olat,代码行数:48,代码来源:FeedManagerImpl.java

示例13: RSSFeed

import com.sun.syndication.feed.synd.SyndEnclosure; //导入依赖的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

示例14: RSSFeed

import com.sun.syndication.feed.synd.SyndEnclosure; //导入依赖的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

示例15: purgeFeed

import com.sun.syndication.feed.synd.SyndEnclosure; //导入依赖的package包/类
/**
 * @param seriesId
 * @param transcodingProfileId
 * @param feed
 */
@SuppressWarnings("rawtypes")
public void purgeFeed(String seriesId, String transcodingProfileId, SyndFeed feed) {
  final File encodingDirectory = new File(feedFilePath, transcodingProfileId);

  // delete feed
  final File feedFile = new File(encodingDirectory, seriesId + feedFileExtension);
  if (feedFile.canWrite()) {
    feedFile.delete();
  }

  // delete feed thumbnail
  final File feedThumbnail = new File(encodingDirectory, seriesId + PNG_EXTENSION);
  if (feedThumbnail.canWrite()) {
    feedThumbnail.delete();
  }

  // delete feed transformation
  final File feedTransformationFile =
      new File(encodingDirectory, seriesId + feedTransformationOutputFileExtension);
  if (feedTransformationFile.canWrite()) {
    feedTransformationFile.delete();
  }

  if (feed != null) {
    final Iterator it = feed.getEntries().iterator();
    while (it.hasNext()) {
      SyndEntry entry = (SyndEntry) it.next();
      final List enclosures = entry.getEnclosures();
      if (enclosures.size() > 0) {
        Iterator enclosureIterator = enclosures.iterator();
        while (enclosureIterator.hasNext()) {
          SyndEnclosure enclosure = (SyndEnclosure) enclosureIterator.next();
          String encUrl = enclosure.getUrl();
          encUrl = encUrl.substring(encUrl.lastIndexOf('/') + 1);

          final TranscodingProfile profile =
              transcodingProfilesDao.findAllProfiles().get(transcodingProfileId);
          if (profile != null) {
            profile.deleteEncoding(this.feedFilePath, enclosure.getUrl(), entry.getUri());
          } else {
            // fabricate a profile for the purpose of deleting the encoding output
            final TranscodingProfile fakeProfile = new TranscodingProfile();
            fakeProfile.setId(transcodingProfileId);
            if (enclosure.getUrl().endsWith(".m3u8")) {
              fakeProfile.setMode(TranscoderType.ONE_PASS_HTTP_SEGMENTED_VOD);
            } else {
              fakeProfile.setMode(TranscoderType.ONE_PASS);
            }

            fakeProfile.deleteEncoding(this.feedFilePath, enclosure.getUrl(), entry.getUri());
          }
        }
      } else {
        LOGGER.debug("No enclosures specified in the entry, continuing");
        continue;
      }
    }
  }

  // delete the encoding profile directory if it is empty following the purge
  if (encodingDirectory.list().length == 0) {
    LOGGER.info("Deleting empty encoding profile directory: "
        + encodingDirectory.getAbsolutePath());
    encodingDirectory.delete();
  }
}
 
开发者ID:skidder,项目名称:mythpodcaster,代码行数:72,代码来源:FeedFileAccessorImpl.java


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