本文整理汇总了Java中com.rometools.rome.io.SyndFeedOutput.output方法的典型用法代码示例。如果您正苦于以下问题:Java SyndFeedOutput.output方法的具体用法?Java SyndFeedOutput.output怎么用?Java SyndFeedOutput.output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rometools.rome.io.SyndFeedOutput
的用法示例。
在下文中一共展示了SyndFeedOutput.output方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
}
示例2: 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);
}
示例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));
}
}
示例4: 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);
}
示例5: 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));
}
}
示例6: 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);
}
示例7: 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);
}
示例8: 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));
}
}
示例9: 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");
}
}
}
示例10: 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());
}
示例11: testEnd2End
import com.rometools.rome.io.SyndFeedOutput; //导入方法依赖的package包/类
public void testEnd2End() throws IOException, FeedException {
final SyndFeed feed = getSyndFeed("thr/threading-main.xml");
final SyndFeedOutput output = new SyndFeedOutput();
File outputFile = new File("target/threading-main-generated.xml");
output.output(feed, outputFile);
final SyndFeed feedOut = getSyndFeed(outputFile);
ThreadingModule moduleSrc = (ThreadingModule) feed.getEntries().get(1).getModule(ThreadingModule.URI);
ThreadingModule moduleOut = (ThreadingModule) feedOut.getEntries().get(1).getModule(ThreadingModule.URI);
assertEquals(moduleSrc, moduleOut);
assertEquals("tag:example.org,2005:1", moduleSrc.getRef());
assertEquals("tag:example.org,2005:1", moduleOut.getRef());
}
示例12: testGenerate
import com.rometools.rome.io.SyndFeedOutput; //导入方法依赖的package包/类
public void testGenerate() throws Exception {
LOG.debug("testGenerate");
final SyndFeedInput input = new SyndFeedInput();
final SyndFeedOutput output = new SyndFeedOutput();
final File testDir = new File(super.getTestFile("xml"));
final File[] testFiles = testDir.listFiles();
for (int h = 0; h < testFiles.length; h++) {
if (!testFiles[h].getName().endsWith(".xml")) {
continue;
}
LOG.debug(testFiles[h].getName());
final SyndFeed feed = input.build(testFiles[h]);
// if( !feed.getFeedType().equals("rss_1.0"))
{
feed.setFeedType("rss_2.0");
if (feed.getDescription() == null) {
feed.setDescription("test file");
}
output.output(feed, new File("target/" + testFiles[h].getName()));
final SyndFeed feed2 = input.build(new File("target/" + testFiles[h].getName()));
for (int i = 0; i < feed.getEntries().size(); i++) {
// FIXME
// final SyndEntry entry = feed.getEntries().get(i);
final SyndEntry entry2 = feed2.getEntries().get(i);
// / FIXME
// final CreativeCommons base = (CreativeCommons)
// entry.getModule(CreativeCommons.URI);
final CreativeCommons base2 = (CreativeCommons) entry2.getModule(CreativeCommons.URI);
LOG.debug("{}", base2);
// FIXME
// if( base != null)
// this.assertEquals( testFiles[h].getName(), base.getLicenses(),
// base2.getLicenses() );
}
}
}
}
示例13: 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(feed.getAbsolutePath() + ".output");
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));
LOG.debug(entry.getModule(AbstractITunesObject.URI).toString());
LOG.debug("-----------------------------------------");
LOG.debug(check.getModule(AbstractITunesObject.URI).toString());
assertEquals("Entry Level: ", entry.getModule(AbstractITunesObject.URI).toString(), check.getModule(AbstractITunesObject.URI).toString());
}
}
示例14: testGenerate
import com.rometools.rome.io.SyndFeedOutput; //导入方法依赖的package包/类
public void testGenerate() throws IOException, FeedException {
final SyndFeed feed = getSyndFeed("thr/threading-main.xml");
List<SyndEntry> entries = feed.getEntries();
// create a new "root" entry that the next entry will reference to
SyndEntry newRootEntry = new SyndEntryImpl();
newRootEntry.setTitle("New, 2nd root entry");
newRootEntry.setUri("tag:example.org,2005:2");
newRootEntry.setLink("http://www.example.org/entries/2");
entries.add(newRootEntry);
// create a new reply entry that will reference the new root entry
SyndEntry newReplyEntry = new SyndEntryImpl();
newReplyEntry.setTitle("New test reply entry");
newReplyEntry.setUri("tag:example.org,2005:2,1");
ThreadingModule threadingModule = new ThreadingModuleImpl();
threadingModule.setRef("tag:example.org,2005:2");
threadingModule.setType("application/xhtml+xml");
threadingModule.setHref("http://www.example.org/entries/2");
threadingModule.setSource("http://example.org/entries/2");
newReplyEntry.getModules().add(threadingModule);
entries.add(newReplyEntry);
File outputFile = new File("target/threading-testGenerate.xml");
final SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, outputFile);
// read back in and validate
final SyndFeed generatedFeed = getSyndFeed(outputFile);
SyndEntry generatedReplyEntry = generatedFeed.getEntries().get(3);
assertNotNull(generatedReplyEntry);
ThreadingModule generatedReplyThreadingModule = (ThreadingModule) generatedReplyEntry.getModule(ThreadingModule.URI);
assertEquals("tag:example.org,2005:2", generatedReplyThreadingModule.getRef());
assertEquals("application/xhtml+xml", generatedReplyThreadingModule.getType());
assertEquals("http://www.example.org/entries/2", generatedReplyThreadingModule.getHref());
assertEquals("http://example.org/entries/2", generatedReplyThreadingModule.getSource());
}
示例15: testGenerate
import com.rometools.rome.io.SyndFeedOutput; //导入方法依赖的package包/类
/**
* Test of generate method, of class com.totsp.xml.syndication.base.io.GoogleBaseGenerator.
*/
public void testGenerate() throws Exception {
LOG.debug("testGenerate");
final SyndFeedInput input = new SyndFeedInput();
final SyndFeedOutput output = new SyndFeedOutput();
final File testDir = new File(super.getTestFile("xml"));
final File[] testFiles = testDir.listFiles();
for (int h = 0; h < testFiles.length; h++) {
if (!testFiles[h].getName().endsWith(".xml")) {
continue;
}
LOG.debug(testFiles[h].getName());
final SyndFeed feed = input.build(testFiles[h]);
try {
output.output(feed, new File("target/" + testFiles[h].getName()));
} catch (final Exception e) {
throw new RuntimeException(testFiles[h].getAbsolutePath(), e);
}
final SyndFeed feed2 = input.build(new File("target/" + testFiles[h].getName()));
for (int i = 0; i < feed.getEntries().size(); i++) {
final SyndEntry entry = feed.getEntries().get(i);
final SyndEntry entry2 = feed2.getEntries().get(i);
final GoogleBase base = (GoogleBase) entry.getModule(GoogleBase.URI);
final GoogleBase base2 = (GoogleBase) entry2.getModule(GoogleBase.URI);
Assert.assertEquals(testFiles[h].getName(), base, base2);
}
}
}