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


Java SyndFeedOutput类代码示例

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


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

示例1: getStreamRssByUserName

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
@Override
public GetStreamRssByUserNameResponse getStreamRssByUserName(String userName) throws Exception {
  StreamingOutput rssOutput = outputStream -> {
    PageRequest pageable = new PageRequest(0, 30);

    SyndFeed feed = new SyndFeedImpl();
    feed.setFeedType("rss_2.0");

    feed.setTitle("PutPut RSS");
    feed.setLink("https://putput.org/api/stream/rss/"+userName);
    feed.setDescription("PutPut feed for @" + userName);

    feed.setEntries(rssEntries(userName, pageable));
    try {
      outputStream.write(new SyndFeedOutput().outputString(feed, true).getBytes("UTF-8"));
    } catch (FeedException e) {
      throw new RuntimeException(e);
    }
  };

  return GetStreamRssByUserNameResponse.withRssxmlOK(rssOutput);
}
 
开发者ID:adrobisch,项目名称:putput,代码行数:23,代码来源:StreamResource.java

示例2: testGenerate

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
public void testGenerate() throws Exception {
    final SyndFeedInput input = new SyndFeedInput();

    final SyndFeed feed = input.build(new File(super.getTestFile("xml/custom-tags-example.xml")));
    final SyndFeedOutput output = new SyndFeedOutput();
    output.output(feed, new File("target/custom-tags-example.xml"));
    final SyndFeed feed2 = input.build(new File("target/custom-tags-example.xml"));

    final List<SyndEntry> entries = feed.getEntries();
    final SyndEntry entry = entries.get(0);
    final CustomTags customTags = (CustomTags) entry.getModule(CustomTags.URI);

    final List<SyndEntry> entries2 = feed2.getEntries();
    final SyndEntry entry2 = entries2.get(0);
    final CustomTags customTags2 = (CustomTags) entry2.getModule(CustomTags.URI);

    final Iterator<CustomTag> it = customTags.getValues().iterator();
    final Iterator<CustomTag> it2 = customTags2.getValues().iterator();
    while (it.hasNext()) {
        final CustomTag tag = it.next();
        final CustomTag tag2 = it2.next();
        LOG.debug("tag1: {}", tag);
        LOG.debug("tag2: {}", tag2);
        Assert.assertEquals(tag, tag2);
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:27,代码来源:CustomTagGeneratorTest.java

示例3: testEndToEnd

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
public void testEndToEnd() throws Exception {
    final SyndFeedInput input = new SyndFeedInput();
    final File test = new File(super.getTestFile("os"));
    final File[] files = test.listFiles();
    for (int j = 0; j < files.length; j++) {
        if (!files[j].getName().endsWith(".xml")) {
            continue;
        }
        final SyndFeed feed = input.build(files[j]);
        final Module m = feed.getModule(OpenSearchModule.URI);
        final SyndFeedOutput output = new SyndFeedOutput();
        final File outfile = new File("target/" + files[j].getName());
        output.output(feed, outfile);
        final SyndFeed feed2 = input.build(outfile);
        assertEquals(m, feed2.getModule(OpenSearchModule.URI));
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:18,代码来源:OpenSearchModuleTest.java

示例4: xtestProduceAndReadGML

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
/**
 * @throws Exception if file not found or not accessible
 */
public void xtestProduceAndReadGML() throws Exception {
    final SyndFeed feed = createFeed();
    final GeoRSSModule geoRSSModule = new GMLModuleImpl();
    final double latitude = 47.0;
    final double longitude = 9.0;
    final Position position = new Position();
    position.setLatitude(latitude);
    position.setLongitude(longitude);
    geoRSSModule.setPosition(position);

    final SyndEntry entry = feed.getEntries().get(0);
    entry.getModules().add(geoRSSModule);

    final SyndFeedOutput output = new SyndFeedOutput();

    final StringWriter stringWriter = new StringWriter();
    output.output(feed, stringWriter);

    final InputStream in = new ByteArrayInputStream(stringWriter.toString().getBytes("UTF8"));
    final Double[] lat = { latitude };
    final Double[] lng = { longitude };
    assertTestInputStream(in, lat, lng);
}
 
开发者ID:rometools,项目名称:rome,代码行数:27,代码来源:GeoRSSModuleTest.java

示例5: testProduceAndReadSimple

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
/**
 * @throws Exception if file not found or not accessible
 */
public void testProduceAndReadSimple() throws Exception {
    final SyndFeed feed = createFeed();
    final GeoRSSModule geoRSSModule = new SimpleModuleImpl();
    final double latitude = 47.0;
    final double longitude = 9.0;
    final Position position = new Position();
    position.setLatitude(latitude);
    position.setLongitude(longitude);
    geoRSSModule.setPosition(position);

    final SyndEntry entry = feed.getEntries().get(0);
    entry.getModules().add(geoRSSModule);

    final SyndFeedOutput output = new SyndFeedOutput();

    final StringWriter stringWriter = new StringWriter();
    output.output(feed, stringWriter);

    final InputStream in = new ByteArrayInputStream(stringWriter.toString().getBytes("UTF8"));
    final Double[] lat = { latitude };
    final Double[] lng = { longitude };
    assertTestInputStream(in, lat, lng);
}
 
开发者ID:rometools,项目名称:rome,代码行数:27,代码来源:GeoRSSModuleTest.java

示例6: compareFeedFiles

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
/**
 * @param expected original file
 * @param generated file for output
 * @throws IOException if file not found or not accessible
 * @throws FeedException when the feed can't be parsed
 */
private void compareFeedFiles(final File expected, final File generated) throws IOException, FeedException {
    final SyndFeed feed = getSyndFeed(expected);
    final List<SyndEntry> entries = feed.getEntries();
    final SyndFeedOutput output = new SyndFeedOutput();
    output.output(feed, generated);
    final SyndFeed feed2 = getSyndFeed(generated);
    for (int i = 0; i < entries.size(); i++) {
        BufferedWriter b = new BufferedWriter(new FileWriter(generated.getAbsolutePath() + ".a.txt"));
        b.write("" + entries.get(i).getModule(MediaModule.URI));
        b.close();
        b = new BufferedWriter(new FileWriter(generated.getAbsolutePath() + ".b.txt"));
        b.write("" + feed2.getEntries().get(i).getModule(MediaModule.URI));
        b.close();
        assertEquals(entries.get(i).getModule(MediaModule.URI), feed2.getEntries().get(i).getModule(MediaModule.URI));
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:23,代码来源:MediaModuleTest.java

示例7: testCreate

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
public void testCreate() throws Exception {

        final SyndFeed feed = new SyndFeedImpl();
        final String feedType = "rss_2.0";
        feed.setFeedType(feedType);
        feed.setLanguage("en-us");
        feed.setTitle("sales.com on the Radio!");
        feed.setDescription("sales.com radio shows in MP3 format");
        feed.setLink("http://foo/rss/podcasts.rss");

        final FeedInformation fi = new FeedInformationImpl();
        fi.setOwnerName("sales.com");
        fi.getCategories().add(new Category("Shopping"));
        fi.setOwnerEmailAddress("[email protected]");
        fi.setType("serial");
        feed.getModules().add(fi);

        final SyndFeedOutput output = new SyndFeedOutput();
        final StringWriter writer = new StringWriter();
        output.output(feed, writer);
        LOG.debug("{}", writer);

    }
 
开发者ID:rometools,项目名称:rome,代码行数:24,代码来源:ITunesGeneratorTest.java

示例8: testGenerate

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
/**
 * Test of generate method, of class com.totsp.xml.syndication.content.ContentModuleGenerator.
 */
public void testGenerate() throws Exception {

    LOG.debug("testGenerate");

    final SyndFeedInput input = new SyndFeedInput();
    final SyndFeed feed = input.build(new XmlReader(new File(getTestFile("xml/test-rdf.xml")).toURI().toURL()));
    final SyndEntry entry = feed.getEntries().get(0);
    entry.getModule(ContentModule.URI);
    final SyndFeedOutput output = new SyndFeedOutput();
    final StringWriter writer = new StringWriter();
    output.output(feed, writer);

    LOG.debug("{}", writer);

}
 
开发者ID:rometools,项目名称:rome,代码行数:19,代码来源:ContentModuleGeneratorTest.java

示例9: xtestParseGenerateV5

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
public void xtestParseGenerateV5() throws Exception {
    final URL feedURL = new File(getTestFile("xml/v/v5.xml")).toURI().toURL();
    // parse the document for comparison
    final SAXBuilder builder = new SAXBuilder();
    final Document directlyBuilt = builder.build(feedURL);

    // generate the feed back into a document
    final SyndFeedInput input = new SyndFeedInput();
    final SyndFeed inputFeed = input.build(new XmlReader(feedURL));

    final SyndFeedOutput output = new SyndFeedOutput();
    final Document parsedAndGenerated = output.outputJDom(inputFeed);

    // XMLOutputter outputter = new XMLOutputter();
    // outputter.setFormat(Format.getPrettyFormat());
    // outputter.output(directlyBuilt, new
    // FileOutputStream("c:\\cygwin\\tmp\\sync-direct.xml"));
    // outputter.output(parsedAndGenerated, new
    // FileOutputStream("c:\\cygwin\\tmp\\sync-pg.xml"));

    assertDocumentsEqual(directlyBuilt, parsedAndGenerated);
}
 
开发者ID:rometools,项目名称:rome,代码行数:23,代码来源:SSEParserTest.java

示例10: testFile

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
private void testFile(final String filename) throws Exception {
    final File feed = new File(getTestFile(filename));
    final SyndFeedInput input = new SyndFeedInput();
    final SyndFeed syndfeed = input.build(new XmlReader(feed.toURI().toURL()));

    final SyndFeedOutput output = new SyndFeedOutput();
    final File outfeed = new File("target/" + feed.getName());
    output.output(syndfeed, outfeed);

    final SyndFeed syndCheck = input.build(new XmlReader(outfeed.toURI().toURL()));
    LOG.debug(syndCheck.getModule(AbstractITunesObject.URI).toString());
    assertEquals("Feed Level: ", syndfeed.getModule(AbstractITunesObject.URI).toString(), syndCheck.getModule(AbstractITunesObject.URI).toString());

    final List<SyndEntry> syndEntries = syndfeed.getEntries();
    final List<SyndEntry> syndChecks = syndCheck.getEntries();

    for (int i = 0; i < syndEntries.size(); i++) {
        final SyndEntry entry = syndEntries.get(i);
        final SyndEntry check = syndChecks.get(i);
        LOG.debug("Original: {}", entry.getModule(AbstractITunesObject.URI));
        LOG.debug("Check:    {}", check.getModule(AbstractITunesObject.URI));
        assertEquals("Entry Level: ", entry.getModule(AbstractITunesObject.URI).toString(), check.getModule(AbstractITunesObject.URI).toString());
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:25,代码来源:ITunesGeneratorTest.java

示例11: testGenerate

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
/**
 * Test of generate method, of class com.rometools.rome.feed.module.photocast.io.Generator.
 */
public void testGenerate() throws Exception {
    final SyndFeedInput input = new SyndFeedInput();

    final SyndFeed feed = input.build(new File(super.getTestFile("index.rss")));
    final List<SyndEntry> entries = feed.getEntries();
    for (int i = 0; i < entries.size(); i++) {
        LOG.debug("{}", entries.get(i).getModule(PhotocastModule.URI));
    }
    final SyndFeedOutput output = new SyndFeedOutput();
    output.output(feed, new File("target/index.rss"));
    final SyndFeed feed2 = input.build(new File("target/index.rss"));
    final List<SyndEntry> entries2 = feed2.getEntries();
    for (int i = 0; i < entries.size(); i++) {
        assertEquals("Module test", entries.get(i).getModule(PhotocastModule.URI), entries2.get(i).getModule(PhotocastModule.URI));
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:20,代码来源:GeneratorTest.java

示例12: testParse

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
/**
 * @throws Exception if file not found or not accessible
 */
public void testParse() throws Exception {
    final File test = new File(super.getTestFile("xml"));
    final File[] files = test.listFiles();
    for (int j = 0; j < files.length; j++) {
        if (!files[j].getName().endsWith(".xml")) {
            continue;
        }
        final SyndFeed feed = getSyndFeed(files[j]);
        final List<SyndEntry> entries = feed.getEntries();
        final SyndFeedOutput output = new SyndFeedOutput();
        output.output(feed, new File("target/" + j + ".xml"));
        final SyndFeed feed2 = getSyndFeed(new File("target/" + j + ".xml"));
        for (int i = 0; i < entries.size(); i++) {
            BufferedWriter b = new BufferedWriter(new FileWriter("target/" + j + "a.txt"));
            b.write("" + entries.get(i).getModule(MediaModule.URI));
            b.close();
            b = new BufferedWriter(new FileWriter("target/" + j + "b.txt"));
            b.write("" + feed2.getEntries().get(i).getModule(MediaModule.URI));
            b.close();
            assertEquals(entries.get(i).getModule(MediaModule.URI), feed2.getEntries().get(i).getModule(MediaModule.URI));
        }
    }
}
 
开发者ID:rometools,项目名称:rome-modules,代码行数:27,代码来源:MediaModuleTest.java

示例13: testCreate

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
public void testCreate() throws Exception {

        final SyndFeed feed = new SyndFeedImpl();
        final String feedType = "rss_2.0";
        feed.setFeedType(feedType);
        feed.setLanguage("en-us");
        feed.setTitle("sales.com on the Radio!");
        feed.setDescription("sales.com radio shows in MP3 format");
        feed.setLink("http://foo/rss/podcasts.rss");

        final FeedInformation fi = new FeedInformationImpl();
        fi.setOwnerName("sales.com");
        fi.getCategories().add(new Category("Shopping"));
        fi.setOwnerEmailAddress("[email protected]");
        feed.getModules().add(fi);

        final SyndFeedOutput output = new SyndFeedOutput();
        final StringWriter writer = new StringWriter();
        output.output(feed, writer);
        LOG.debug("{}", writer);

    }
 
开发者ID:rometools,项目名称:rome-modules,代码行数:23,代码来源:ITunesGeneratorTest.java

示例14: doGet

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
@Override
protected void doGet () throws ServletException, IOException {
	super.doGet();

	Property generateRss = PropertyServiceProvider.provide()
			.getNamedProperty(PropertyHelper.GENERATE_RSS_FEED);

	if (PropertyHelper.isEmpty(generateRss)
			|| Boolean.valueOf(generateRss.value).booleanValue()) {

		HttpServletRequest request = REQUEST.get();
		HttpServletResponse response = RESPONSE.get();

		try {
			SyndFeed feed = getFeed(request);

			String feedType = request.getParameter(FEED_TYPE);
			feedType = (feedType != null) ? feedType : defaultFeedType;
			feed.setFeedType(feedType);

			response.setContentType(MIME_TYPE);
			SyndFeedOutput output = new SyndFeedOutput();
			output.output(feed, response.getWriter());
		} catch (FeedException ex) {
			response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
					"Could not generate feed");
		}
	}
}
 
开发者ID:billy1380,项目名称:blogwt,代码行数:30,代码来源:FeedServlet.java

示例15: writeRevisionsFeed

import com.rometools.rome.io.SyndFeedOutput; //导入依赖的package包/类
private void writeRevisionsFeed(HttpServletRequest request, HttpServletResponse response, ServiceMap serviceMap) throws IOException, FeedException, ServiceException, PublicInterfaceNotFoundException {
	long poid = Long.parseLong(request.getParameter("poid"));
	SProject sProject = serviceMap.getServiceInterface().getProjectByPoid(poid);

	SyndFeed feed = new SyndFeedImpl();
	feed.setFeedType(FEED_TYPE);

	feed.setTitle("BIMserver.org revisions feed for project '" + sProject.getName() + "'");
	feed.setLink(request.getContextPath());
	feed.setDescription("This feed represents all the revisions of project '" + sProject.getName() + "'");

	List<SyndEntry> entries = new ArrayList<SyndEntry>();
	try {
		List<SRevision> allRevisionsOfProject = serviceMap.getServiceInterface().getAllRevisionsOfProject(poid);
		Collections.sort(allRevisionsOfProject, new SRevisionIdComparator(false));
		for (SRevision sVirtualRevision : allRevisionsOfProject) {
			SUser user = serviceMap.getServiceInterface().getUserByUoid(sVirtualRevision.getUserId());
			SyndEntry entry = new SyndEntryImpl();
			entry.setTitle("Revision " + sVirtualRevision.getOid());
			entry.setLink(request.getContextPath() + "/revision.jsp?poid=" + sVirtualRevision.getOid() + "&roid=" + sVirtualRevision.getOid());
			entry.setPublishedDate(sVirtualRevision.getDate());
			SyndContent description = new SyndContentImpl();
			description.setType("text/html");
			description.setValue("<table><tr><td>User</td><td>" + user.getUsername() + "</td></tr><tr><td>Comment</td><td>" + sVirtualRevision.getComment()
					+ "</td></tr></table>");
			entry.setDescription(description);
			entries.add(entry);
		}
	} catch (ServiceException e) {
		LOGGER.error("", e);
	}
	feed.setEntries(entries);
	SyndFeedOutput output = new SyndFeedOutput();
	output.output(feed, response.getWriter());
}
 
开发者ID:opensourceBIM,项目名称:BIMserver,代码行数:36,代码来源:SyndicationServlet.java


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