本文整理汇总了Java中com.rometools.rome.feed.atom.Feed.setEntries方法的典型用法代码示例。如果您正苦于以下问题:Java Feed.setEntries方法的具体用法?Java Feed.setEntries怎么用?Java Feed.setEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rometools.rome.feed.atom.Feed
的用法示例。
在下文中一共展示了Feed.setEntries方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: buildFeedEntries
import com.rometools.rome.feed.atom.Feed; //导入方法依赖的package包/类
/**
* Invokes {@link #buildFeedEntries(Map, HttpServletRequest, HttpServletResponse)}
* to get a list of feed entries.
*/
@Override
protected final void buildFeedEntries(Map<String, Object> model, Feed feed,
HttpServletRequest request, HttpServletResponse response) throws Exception {
List<Entry> entries = buildFeedEntries(model, request, response);
feed.setEntries(entries);
}
示例3: write
import com.rometools.rome.feed.atom.Feed; //导入方法依赖的package包/类
@Test
public void write() throws IOException, SAXException {
Feed feed = new Feed("atom_1.0");
feed.setTitle("title");
Entry entry1 = new Entry();
entry1.setId("id1");
entry1.setTitle("title1");
Entry entry2 = new Entry();
entry2.setId("id2");
entry2.setTitle("title2");
List<Entry> entries = new ArrayList<Entry>(2);
entries.add(entry1);
entries.add(entry2);
feed.setEntries(entries);
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
converter.write(feed, null, outputMessage);
assertEquals("Invalid content-type", new MediaType("application", "atom+xml", utf8),
outputMessage.getHeaders().getContentType());
String expected = "<feed xmlns=\"http://www.w3.org/2005/Atom\">" + "<title>title</title>" +
"<entry><id>id1</id><title>title1</title></entry>" +
"<entry><id>id2</id><title>title2</title></entry></feed>";
assertXMLEqual(expected, outputMessage.getBodyAsString(utf8));
}
示例4: testGenerator
import com.rometools.rome.feed.atom.Feed; //导入方法依赖的package包/类
/**
* Generator-Test (Simplified INSPIRE Service Feed)
* @throws com.rometools.rome.io.FeedException
* @throws java.io.IOException
*/
public void testGenerator() throws FeedException, IOException {
// Atom Container-Element
Feed atomFeed = new Feed();
atomFeed.setEncoding("utf-8");
atomFeed.setTitle("Digitales Geländemodell 200m Bayern - INSPIRE Atom Example");
atomFeed.setUpdated(new Date());
// Atom Entry-Element
Entry atomEntry = new Entry();
atomEntry.setTitle("Digitales Geländemodell 200m Bayern - INSPIRE Atom Example");
atomEntry.setUpdated(new Date());
// GeoRSS-Extension (Bounding-Box)
GeoRSSModule geoRssModule = new SimpleModuleImpl();
geoRssModule.setGeometry(new Envelope(47.2279397510939845, 8.8934968721451053, 50.5798028875686470, 13.9247471058637764));
// INSPIRE_DLS-Extension
InspireDlsModule inspireDlsModule = new InspireDlsModuleImpl();
SpatialDatasetIdentifier identifier = new SpatialDatasetIdentifier();
identifier.setCode("DEBY_1d4ab890-27e7-3ebb-95ba-2d2ab8071871");
identifier.setNamespace("http://www.geodaten.bayern.de");
inspireDlsModule.setSpatialDatasetIdentifier(identifier);
List<Module> modules = new ArrayList<Module>();
modules.add(geoRssModule);
modules.add(inspireDlsModule);
atomEntry.setModules(modules);
atomFeed.setEntries(Arrays.asList(atomEntry));
// build JDOM-Document
Document atomXml = new Atom10Generator().generate(atomFeed);
// print JDOM-Document to System.out
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
outputter.output(atomXml, System.out);
}
示例5: parseFeed
import com.rometools.rome.feed.atom.Feed; //导入方法依赖的package包/类
protected WireFeed parseFeed(final Element eFeed, final Locale locale) throws FeedException {
String baseURI = null;
try {
baseURI = findBaseURI(eFeed);
} catch (final Exception e) {
throw new FeedException("ERROR while finding base URI of feed", e);
}
final Feed feed = parseFeedMetadata(baseURI, eFeed, locale);
feed.setStyleSheet(getStyleSheet(eFeed.getDocument()));
final String xmlBase = eFeed.getAttributeValue("base", Namespace.XML_NAMESPACE);
if (xmlBase != null) {
feed.setXmlBase(xmlBase);
}
feed.setModules(parseFeedModules(eFeed, locale));
final List<Element> eList = eFeed.getChildren("entry", getAtomNamespace());
if (!eList.isEmpty()) {
feed.setEntries(parseEntries(feed, baseURI, eList, locale));
}
final List<Element> foreignMarkup = extractForeignMarkup(eFeed, feed, getAtomNamespace());
if (!foreignMarkup.isEmpty()) {
feed.setForeignMarkup(foreignMarkup);
}
return feed;
}