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


Java SyndFeed.getModule方法代码示例

本文整理汇总了Java中com.rometools.rome.feed.synd.SyndFeed.getModule方法的典型用法代码示例。如果您正苦于以下问题:Java SyndFeed.getModule方法的具体用法?Java SyndFeed.getModule怎么用?Java SyndFeed.getModule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.rometools.rome.feed.synd.SyndFeed的用法示例。


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

示例1: getGeoRSS

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
/**
 * This convenience method checks whether there is any geoRss Element and will return it (georss
 * simple or W3GGeo).
 *
 * @param feed the element in the feed which might have a georss element
 * @return a georssmodule or null if none is present
 */
public static GeoRSSModule getGeoRSS(final SyndFeed feed) {
    final GeoRSSModule simple = (GeoRSSModule) feed.getModule(GeoRSSModule.GEORSS_GEORSS_URI);
    final GeoRSSModule w3cGeo = (GeoRSSModule) feed.getModule(GeoRSSModule.GEORSS_W3CGEO_URI);
    final GeoRSSModule gml = (GeoRSSModule) feed.getModule(GeoRSSModule.GEORSS_GML_URI);

    if (gml != null) {
        return gml;
    }
    if (simple != null) {
        return simple;
    }
    if (w3cGeo != null) {
        return w3cGeo;
    }

    return null;
    /*
     * if (geoRSSModule == null && w3cGeo != null) { geoRSSModule = w3cGeo; } else if
     * (geoRSSModule == null && gml != null) { geoRSSModule = gml; } else if (geoRSSModule !=
     * null && w3cGeo != null) { // sanity check if
     * (!geoRSSModule.getGeometry().equals(w3cGeo.getGeometry())) { throw new
     * Error("geometry of simple and w3c do not match"); } } return geoRSSModule;
     */
}
 
开发者ID:rometools,项目名称:rome,代码行数:32,代码来源:GeoRSSUtils.java

示例2: testEndToEnd

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的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

示例3: testParse

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
/**
 * Test of parse method, of class com.rometools.rome.feed.module.sle.io.ModuleParser.
 */
public void testParse() throws Exception {
    final SyndFeedInput input = new SyndFeedInput();
    final SyndFeed feed = input.build(new File(super.getTestFile("data/bookexample.xml")));
    final SimpleListExtension sle = (SimpleListExtension) feed.getModule(SimpleListExtension.URI);
    // LOG.debug( sle );
    assertEquals("list", sle.getTreatAs());
    final Group[] groups = sle.getGroupFields();
    assertEquals("genre", groups[0].getElement());
    assertEquals("Genre", groups[0].getLabel());
    final Sort[] sorts = sle.getSortFields();
    assertEquals("Relevance", sorts[0].getLabel());
    assertTrue(sorts[0].getDefaultOrder());
    assertEquals(sorts[1].getNamespace(), Namespace.getNamespace("http://www.example.com/book"));
    assertEquals(sorts[1].getDataType(), Sort.DATE_TYPE);
    assertEquals(sorts[1].getElement(), "firstedition");
    final SyndEntry entry = feed.getEntries().get(0);
    final SleEntry sleEntry = (SleEntry) entry.getModule(SleEntry.URI);
    LOG.debug("{}", sleEntry);
    LOG.debug("getGroupByElement");
    LOG.debug("{}", sleEntry.getGroupByElement(groups[0]));
    LOG.debug("getSortByElement");
    LOG.debug("{}", sleEntry.getSortByElement(sorts[0]));
}
 
开发者ID:rometools,项目名称:rome-modules,代码行数:27,代码来源:ModuleParserTest.java

示例4: atestParse

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
public void atestParse() throws Exception {

        final SyndFeedInput input = new SyndFeedInput();
        final File testDir = new File(super.getTestFile("test/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]);
            final List<SyndEntry> entries = feed.getEntries();
            final CreativeCommons fMod = (CreativeCommons) feed.getModule(CreativeCommons.URI);
            LOG.debug("{}", fMod);
            for (int i = 0; i < entries.size(); i++) {
                final SyndEntry entry = entries.get(i);
                final CreativeCommons eMod = (CreativeCommons) entry.getModule(CreativeCommons.URI);
                LOG.debug("\nEntry:");
                LOG.debug("{}", eMod);
            }
        }
    }
 
开发者ID:rometools,项目名称:rome,代码行数:23,代码来源:ModuleParserTest.java

示例5: testParse

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
/**
 * Test of parse method, of class com.rometools.rome.feed.module.sle.io.ModuleParser.
 */
public void testParse() throws Exception {
    final SyndFeedInput input = new SyndFeedInput();
    final SyndFeed feed = input.build(new File(super.getTestFile("data/bookexample.xml")));
    final SimpleListExtension sle = (SimpleListExtension) feed.getModule(SimpleListExtension.URI);

    assertEquals("list", sle.getTreatAs());
    final Group[] groups = sle.getGroupFields();
    assertEquals("genre", groups[0].getElement());
    assertEquals("Genre", groups[0].getLabel());
    final Sort[] sorts = sle.getSortFields();
    assertEquals("Relevance", sorts[0].getLabel());
    assertTrue(sorts[0].getDefaultOrder());
    assertEquals(sorts[1].getNamespace(), Namespace.getNamespace("http://www.example.com/book"));
    assertEquals(sorts[1].getDataType(), Sort.DATE_TYPE);
    assertEquals(sorts[1].getElement(), "firstedition");
    final SyndEntry entry = feed.getEntries().get(0);
    final SleEntry sleEntry = (SleEntry) entry.getModule(SleEntry.URI);
    LOG.debug("{}", sleEntry);
    LOG.debug("getGroupByElement");
    LOG.debug("{}", sleEntry.getGroupByElement(groups[0]));
    LOG.debug("getSortByElement");
    LOG.debug("{}", sleEntry.getSortByElement(sorts[0]));
}
 
开发者ID:rometools,项目名称:rome,代码行数:27,代码来源:ModuleParserTest.java

示例6: test

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
public void test() throws Exception {

        final File testdata = new File(super.getTestFile("atom/atom.xml"));
        final SyndFeed feed = new SyndFeedInput().build(testdata);

        final AtomLinkModule atomLinkModule = (AtomLinkModule) feed.getModule(AtomLinkModule.URI);
        List<Link> links = atomLinkModule.getLinks();
        for (int i = 0; i < links.size(); i++) {
            Link link = links.get(i);
            assertEquals(href[i], link.getHref());
            assertEquals(rel[i], link.getRel());
            assertEquals(type[i], link.getType());
        }

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

示例7: testSort2

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
/**
 * Test of sort method, of class com.rometools.rome.feed.module.sle.GroupAndSort.
 */
public void testSort2() throws Exception {

    final SyndFeedInput input = new SyndFeedInput();
    final SyndFeed feed = input.build(new File(super.getTestFile("data/YahooTopSongs.xml")));
    final SimpleListExtension sle = (SimpleListExtension) feed.getModule(SimpleListExtension.URI);

    final List<Extendable> entries = new ArrayList<Extendable>(feed.getEntries());
    final List<Extendable> sortedEntries = SleUtility.sort(entries, sle.getSortFields()[0], true);
    for (int i = 0; i < sortedEntries.size(); i++) {
        final SyndEntry entry = (SyndEntry) sortedEntries.get(i);
        LOG.debug(entry.getTitle());
    }

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

示例8: testCustomModule

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
@Test
public void testCustomModule() throws Exception {
    final XmlReader reader = new XmlReader(getClass().getResourceAsStream("custom-module.xml"));
    final SyndFeed feed = new SyndFeedInput().build(reader);

    final CustomModule customModule = (CustomModule) feed.getModule(CustomModule.URI);

    assertNotNull(customModule);
    assertEquals("test-title", customModule.getTitle());
}
 
开发者ID:rometools,项目名称:rome,代码行数:11,代码来源:CustomModuleIT.java

示例9: testDefaultClassLoader

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
@Test
public void testDefaultClassLoader() throws Exception {
    final XmlReader reader = new XmlReader(getClass().getResourceAsStream("custom-module.xml"));
    final SyndFeed feed = new SyndFeedInput().build(reader);

    final CustomModule customModule = (CustomModule) feed.getModule(CustomModule.URI);

    assertNull(customModule);
}
 
开发者ID:rometools,项目名称:rome,代码行数:10,代码来源:CustomModuleOsgiIT.java

示例10: testConfigurableCompositeClassLoader

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
@Test
public void testConfigurableCompositeClassLoader() throws Exception {
    final ClassLoader thisClassLoader = getClass().getClassLoader();
    final ClassLoader romeClassLoader = ConfigurableClassLoader.INSTANCE.getClassLoader();
    ConfigurableClassLoader.INSTANCE.setClassLoader(new CompositeClassLoader(thisClassLoader, romeClassLoader));

    final XmlReader reader = new XmlReader(getClass().getResourceAsStream("custom-module.xml"));
    final SyndFeed feed = new SyndFeedInput().build(reader);

    final CustomModule customModule = (CustomModule) feed.getModule(CustomModule.URI);

    assertNotNull(customModule);
    assertEquals("test-title", customModule.getTitle());
}
 
开发者ID:rometools,项目名称:rome,代码行数:15,代码来源:CustomModuleOsgiIT.java

示例11: test

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    final XmlReader reader = new XmlReader(getClass().getResourceAsStream("modules.xml"));
    final SyndFeed feed = new SyndFeedInput().build(reader);
    final FeedInformation itunes = (FeedInformation) feed.getModule(ITunes.URI);

    assertNotNull(itunes);
    assertEquals("test-author", itunes.getAuthor());
}
 
开发者ID:rometools,项目名称:rome,代码行数:10,代码来源:ModulesIT.java

示例12: testGenerate

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
/**
 * Test of generate method, of class com.totsp.xml.syndication.base.io.SlashGenerator.
 *
 * @throws Exception on error
 */
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("processing" + testFiles[h]);
        final SyndFeed feed = input.build(testFiles[h]);
        output.output(feed, new File("target/" + testFiles[h].getName()));
        final SyndFeed feed2 = input.build(new File("target/" + testFiles[h].getName()));
        final YWeatherModule weather = (YWeatherModule) feed.getModule(YWeatherModule.URI);
        final YWeatherModule weather2 = (YWeatherModule) feed2.getModule(YWeatherModule.URI);
        Assert.assertEquals(testFiles[h].getName(), weather, weather2);
        for (int i = 0; i < feed.getEntries().size(); i++) {
            final SyndEntry entry = feed.getEntries().get(i);
            final SyndEntry entry2 = feed2.getEntries().get(i);
            final YWeatherModule weatherEntry = (YWeatherModule) entry.getModule(YWeatherModule.URI);
            final YWeatherModule weatherEntry2 = (YWeatherModule) entry2.getModule(YWeatherModule.URI);
            assertEquals(testFiles[h].getName(), weatherEntry, weatherEntry2);
        }
    }

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

示例13: testSort

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
/**
 * Test of sort method, of class com.rometools.rome.feed.module.sle.GroupAndSort.
 */
public void testSort() throws Exception {

    final File testdata = new File(super.getTestFile("data/bookexample.xml"));
    final SyndFeed feed = new SyndFeedInput().build(testdata);

    List<SyndEntry> entries = feed.getEntries();

    final SimpleListExtension extention = (SimpleListExtension) feed.getModule(SimpleListExtension.URI);
    final Sort[] sortFields = extention.getSortFields();

    final Sort sortByDate = sortFields[1];
    final Sort sortByTitle = sortFields[2];

    // sort by date ascending
    List<SyndEntry> sortedEntries = SleUtility.sort(entries, sortByDate, true);
    SyndEntry entry = sortedEntries.get(0);
    assertEquals("Great Journeys of the Past", entry.getTitle());

    // sort by date descending
    sortedEntries = SleUtility.sort(entries, sortByDate, false);
    entry = sortedEntries.get(0);
    assertEquals("Horror Stories, vol 16", entry.getTitle());

    // sort by date ascending
    sortedEntries = SleUtility.sort(entries, sortByDate, true);

    // update first entry and reinitialize
    entry = sortedEntries.get(0);
    entry.setTitle("ZZZZZ");
    SleUtility.initializeForSorting(feed);
    entries = feed.getEntries();

    // sort by title desc
    sortedEntries = SleUtility.sort(entries, sortByTitle, false);
    entry = sortedEntries.get(0);
    assertEquals("ZZZZZ", entry.getTitle());

    // sort by title asc
    sortedEntries = SleUtility.sort(entries, sortByTitle, true);
    entry = sortedEntries.get(0);
    assertEquals("Horror Stories, vol 16", entry.getTitle());

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

示例14: testSortAndGroup

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
/**
 * Test of sortAndGroup method, of class com.rometools.rome.feed.module.sle.GroupAndSort.
 */
public void testSortAndGroup() throws Exception {

    final File testdata = new File(super.getTestFile("data/bookexample.xml"));
    final SyndFeed feed = new SyndFeedInput().build(testdata);

    final List<SyndEntry> feedEntries = feed.getEntries();
    final List<Extendable> entries = new ArrayList<Extendable>(feedEntries);

    final SimpleListExtension sle = (SimpleListExtension) feed.getModule(SimpleListExtension.URI);
    final Sort[] sortFields = sle.getSortFields();

    final Sort sortByTitle = sortFields[2];

    final List<Extendable> sortedEntries = SleUtility.sortAndGroup(entries, sle.getGroupFields(), sortByTitle, true);
    final SyndEntry entry = (SyndEntry) sortedEntries.get(0);
    assertEquals("Horror Stories, vol 16", entry.getTitle());

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

示例15: test

import com.rometools.rome.feed.synd.SyndFeed; //导入方法依赖的package包/类
public void test() throws Exception {

        final File testdata = new File(super.getTestFile("atom/atom.xml"));
        final SyndFeed feed = new SyndFeedInput().build(testdata);

        final AtomLinkModule atomLinkModule = (AtomLinkModule) feed.getModule(AtomLinkModule.URI);
        Link link = atomLinkModule.getLink();

        assertEquals(href, link.getHref());
        assertEquals(rel, link.getRel());
        assertEquals(type, link.getType());

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


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