本文整理汇总了Java中com.rometools.rome.feed.synd.SyndFeed.setFeedType方法的典型用法代码示例。如果您正苦于以下问题:Java SyndFeed.setFeedType方法的具体用法?Java SyndFeed.setFeedType怎么用?Java SyndFeed.setFeedType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rometools.rome.feed.synd.SyndFeed
的用法示例。
在下文中一共展示了SyndFeed.setFeedType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreate
import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的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);
}
示例2: testCreate
import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的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: doGet
import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的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");
}
}
}
示例4: verifyFeedSerialization
import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
@Test
public void verifyFeedSerialization() throws IOException, ClassNotFoundException, CloneNotSupportedException, FeedException {
SyndFeed feed1 = new SyndFeedImpl();
feed1.setFeedType("atom_1.0");
feed1.setUri("foobar");
String s = FeedCacheUtils.feedToString(feed1);
SyndFeed feed2 = FeedCacheUtils.feedFromString(s);
assertThat(feed2, IsEqual.equalTo(feed1));
}
示例5: writeRevisionsFeed
import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的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());
}
示例6: writeCheckoutsFeed
import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
private void writeCheckoutsFeed(HttpServletRequest request, HttpServletResponse response, ServiceMap serviceMap) throws ServiceException, IOException, FeedException, 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 checkouts feed for project '" + sProject.getName() + "'");
feed.setLink(request.getContextPath());
feed.setDescription("This feed represents all the checkouts of project '" + sProject.getName() + "'");
List<SyndEntry> entries = new ArrayList<SyndEntry>();
try {
List<SCheckout> allCheckoutsOfProject = serviceMap.getServiceInterface().getAllCheckoutsOfProjectAndSubProjects(poid);
for (SCheckout sCheckout : allCheckoutsOfProject) {
SRevision revision = serviceMap.getServiceInterface().getRevision(sCheckout.getRevision().getOid());
SProject project = serviceMap.getServiceInterface().getProjectByPoid(sCheckout.getProjectId());
SUser user = serviceMap.getServiceInterface().getUserByUoid(sCheckout.getUserId());
SyndEntry entry = new SyndEntryImpl();
entry.setTitle("Checkout on " + project.getName() + ", revision " + revision.getId());
entry.setLink(request.getContextPath() + "/project.jsp?poid=" + sProject.getOid());
entry.setPublishedDate(sCheckout.getDate());
SyndContent description = new SyndContentImpl();
description.setType("text/plain");
description
.setValue("<table><tr><td>User</td><td>" + user.getUsername() + "</td></tr><tr><td>Revision</td><td>" + sCheckout.getRevision().getOid() + "</td></tr></table>");
entry.setDescription(description);
entries.add(entry);
}
} catch (UserException e) {
LOGGER.error("", e);
}
feed.setEntries(entries);
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, response.getWriter());
}
示例7: testGenerate
import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的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() );
}
}
}
}
示例8: copyInto
import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
/**
* Makes a deep copy/conversion of the values of a real feed into a SyndFeedImpl.
* <p>
* It assumes the given SyndFeedImpl has no properties set.
* <p>
*
* @param feed real feed to copy/convert.
* @param syndFeed the SyndFeedImpl that will contain the copied/converted values of the real feed.
*/
@Override
public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {
final Opml opml = (Opml) feed;
syndFeed.setTitle(opml.getTitle());
addOwner(opml, syndFeed);
syndFeed.setPublishedDate(opml.getModified() != null ? opml.getModified() : opml.getCreated());
syndFeed.setFeedType(opml.getFeedType());
syndFeed.setModules(opml.getModules());
syndFeed.setFeedType(getType());
createEntries(new Stack<Integer>(), syndFeed.getEntries(), opml.getOutlines());
}
示例9: run
import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
@Override
public void run()
{
// Not terribly efficient
AbstractRootSearchSection<?> rootSearch = info.lookupSection(AbstractRootSearchSection.class);
AbstractFreetextResultsSection<?, ?> searchResults = info
.lookupSection(AbstractFreetextResultsSection.class);
FreetextSearchEvent event = searchResults.createSearchEvent(info);
info.processEvent(event);
FreetextSearchResults<FreetextResult> results = freeTextService.search(event.getFinalSearch(), 0, length);
if( feedType.equals("rss_2.0") )
{
response.setContentType("application/rss+xml; charset=UTF-8");
}
else
{
response.setContentType("application/atom+xml; charset=UTF-8");
}
SyndFeed feed = getFeed(info, searchResults, results);
feed.setFeedType(feedType);
String title = rootSearch.getTitle(info).getText();
feed.setTitle(title);
String urlPath = path;
if( urlPath != null && urlPath.startsWith("/") )
{
urlPath = urlPath.substring(1);
}
feed.setLink(institutionService.institutionalise(urlPath));
feed.setDescription(title);
WireFeed wfeed = feed.createWireFeed(feedType);
if( wfeed instanceof Feed )
{
// add compulsory Atom fields
Feed atomFeed = (Feed) wfeed;
atomFeed.setId(institutionService.institutionalise("atom_1.0"));
atomFeed.setUpdated(new Date());
}
WireFeedOutput outputter = new WireFeedOutput();
try
{
outputter.output(wfeed, response.getWriter());
}
catch( Exception fe )
{
throw new RuntimeException(fe);
}
}
示例10: testSyndFeedNotEqual
import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
public void testSyndFeedNotEqual() throws Exception {
final SyndFeed feed1 = this.getCachedSyndFeed();
final SyndFeed feed2 = getSyndFeed(false);
feed2.setFeedType("dummy");
assertFalse(feed1.equals(feed2));
}
示例11: testSyndFeedNotEqual
import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
public void testSyndFeedNotEqual() throws Exception {
final SyndFeed feed1 = getCachedSyndFeed();
final SyndFeed feed2 = getSyndFeed();
feed2.setFeedType("dummy");
assertFalse(feed1.equals(feed2));
}
示例12: main
import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
public static void main(final String[] args) {
boolean ok = false;
if (args.length >= 2) {
try {
final String outputType = args[0];
final SyndFeed feed = new SyndFeedImpl();
feed.setFeedType(outputType);
feed.setTitle("Aggregated Feed");
feed.setDescription("Anonymous Aggregated Feed");
feed.setAuthor("anonymous");
feed.setLink("http://www.anonymous.com");
final List<SyndEntry> entries = new ArrayList<SyndEntry>();
feed.setEntries(entries);
final FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance();
final FeedFetcher feedFetcher = new HttpURLFeedFetcher(feedInfoCache);
for (int i = 1; i < args.length; i++) {
final URL inputUrl = new URL(args[i]);
final SyndFeed inFeed = feedFetcher.retrieveFeed(inputUrl);
entries.addAll(inFeed.getEntries());
}
final SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, new PrintWriter(System.out));
ok = true;
} catch (final Exception ex) {
System.out.println("ERROR: " + ex.getMessage());
ex.printStackTrace();
}
}
if (!ok) {
System.out.println();
System.out.println("FeedAggregator aggregates different feeds into a single one.");
System.out.println("The first parameter must be the feed type for the aggregated feed.");
System.out.println(" [valid values are: rss_0.9, rss_0.91, rss_0.92, rss_0.93, ]");
System.out.println(" [ rss_0.94, rss_1.0, rss_2.0 & atom_0.3 ]");
System.out.println("The second to last parameters are the URLs of feeds to aggregate.");
System.out.println();
}
}