本文整理汇总了Java中com.rometools.rome.feed.atom.Feed.setFeedType方法的典型用法代码示例。如果您正苦于以下问题:Java Feed.setFeedType方法的具体用法?Java Feed.setFeedType怎么用?Java Feed.setFeedType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rometools.rome.feed.atom.Feed
的用法示例。
在下文中一共展示了Feed.setFeedType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseEntry
import com.rometools.rome.feed.atom.Feed; //导入方法依赖的package包/类
/**
* Parse entry from reader.
*/
public static Entry parseEntry(final Reader rd, final String baseURI, final Locale locale) throws JDOMException, IOException, IllegalArgumentException,
FeedException {
// Parse entry into JDOM tree
final SAXBuilder builder = new SAXBuilder();
final Document entryDoc = builder.build(rd);
final Element fetchedEntryElement = entryDoc.getRootElement();
fetchedEntryElement.detach();
// Put entry into a JDOM document with 'feed' root so that Rome can
// handle it
final Feed feed = new Feed();
feed.setFeedType("atom_1.0");
final WireFeedOutput wireFeedOutput = new WireFeedOutput();
final Document feedDoc = wireFeedOutput.outputJDom(feed);
feedDoc.getRootElement().addContent(fetchedEntryElement);
if (baseURI != null) {
feedDoc.getRootElement().setAttribute("base", baseURI, Namespace.XML_NAMESPACE);
}
final WireFeedInput input = new WireFeedInput(false, locale);
final Feed parsedFeed = (Feed) input.build(feedDoc);
return parsedFeed.getEntries().get(0);
}
示例2: serializeEntry
import com.rometools.rome.feed.atom.Feed; //导入方法依赖的package包/类
/**
* Utility method to serialize an entry to writer.
*/
public static void serializeEntry(final Entry entry, final Writer writer) throws IllegalArgumentException, FeedException, IOException {
// Build a feed containing only the entry
final List<Entry> entries = new ArrayList<Entry>();
entries.add(entry);
final Feed feed1 = new Feed();
feed1.setFeedType("atom_1.0");
feed1.setEntries(entries);
// Get Rome to output feed as a JDOM document
final WireFeedOutput wireFeedOutput = new WireFeedOutput();
final Document feedDoc = wireFeedOutput.outputJDom(feed1);
// Grab entry element from feed and get JDOM to serialize it
final Element entryElement = feedDoc.getRootElement().getChildren().get(0);
final XMLOutputter outputter = new XMLOutputter();
outputter.output(entryElement, writer);
}
示例3: createFeed
import com.rometools.rome.feed.atom.Feed; //导入方法依赖的package包/类
private Feed createFeed() {
final Feed feed = new Feed();
final Content content = new Content();
content.setType("application/xml");
content.setValue("<test>Hello Hello</test>");
feed.setTitleEx(content);
feed.setFeedType("atom_1.0");
return feed;
}