Package com.rometools.rome.feed.synd

Examples of com.rometools.rome.feed.synd.SyndEntryImpl


        SyndFeedInput input = new SyndFeedInput();
        SyndFeed feed = input.build(new XmlReader(getClass().getResource("/reuters/rss.xml")));

        assertThat(feed.getEntries().size(), greaterThan(0));
        for (Object o : feed.getEntries()) {
            SyndEntryImpl message = (SyndEntryImpl) o;
            XContentBuilder xcb = toJson(message, null, null, true);
            assertThat(xcb, notNullValue());
        }
  }
View Full Code Here


        }
  }

    @Test
    public void shouldParseRssGeoInformation() throws Exception {
        final SyndEntryImpl entry = buildEntry();
        final XContentBuilder xContentBuilder = RssToJson.toJson(entry, null, null, true);
        assertThat(xContentBuilder.string(), equalTo(JSON));
    }
View Full Code Here

        SyndFeedInput input = new SyndFeedInput();
        SyndFeed feed = input.build(new XmlReader(getClass().getResource("/dcrainmaker/rss.xml")));

        assertThat(feed.getEntries().size(), greaterThan(0));
        for (Object o : feed.getEntries()) {
            SyndEntryImpl message = (SyndEntryImpl) o;
            XContentBuilder xcb = toJson(message, null, null, true);
            assertThat(xcb, notNullValue());
            assertThat(xcb.string(), containsString("<p>"));
            logger.info(xcb.string());
        }
View Full Code Here

        SyndFeedInput input = new SyndFeedInput();
        SyndFeed feed = input.build(new XmlReader(getClass().getResource("/dcrainmaker/rss.xml")));

        assertThat(feed.getEntries().size(), greaterThan(0));
        for (Object o : feed.getEntries()) {
            SyndEntryImpl message = (SyndEntryImpl) o;
            XContentBuilder xcb = toJson(message, null, null, false);
            assertThat(xcb, notNullValue());
            assertThat(xcb.string(), new SubstringMatcher("<p>") {
                @Override
                protected boolean evalSubstringOf(String s) {
View Full Code Here

        assertThat(feed, notNullValue());
        assertThat(feed.getEntries().isEmpty(), equalTo(false));

        for (Object o : feed.getEntries()) {
            assertThat(o, instanceOf(SyndEntryImpl.class));
            SyndEntryImpl entry = (SyndEntryImpl) o;

            GeoRSSModule geoRSSModule = GeoRSSUtils.getGeoRSS(entry);
            assertThat(geoRSSModule, notNullValue());

            Position position = geoRSSModule.getPosition();
View Full Code Here

    return entry;
  }

  public SyndEntry asRss() {
    SyndEntry entry = new SyndEntryImpl();

    entry.setUri(getGuid());
    entry.setTitle(getTitle());

    SyndContentImpl content = new SyndContentImpl();
    content.setValue(getContent());
    entry.setContents(Arrays.<SyndContent> asList(content));
    entry.setLink(getUrl());
    entry.setPublishedDate(getDate());
    return entry;
  }
View Full Code Here

        return syndEntries;
    }

    protected SyndEntry createSyndEntry(final Item item, final boolean preserveWireItem) {

        final SyndEntryImpl syndEntry = new SyndEntryImpl();

        if (preserveWireItem) {
            syndEntry.setWireEntry(item);
        }

        syndEntry.setModules(ModuleUtils.cloneModules(item.getModules()));

        final List<Element> foreignMarkup = item.getForeignMarkup();
        if (!foreignMarkup.isEmpty()) {
            syndEntry.setForeignMarkup(foreignMarkup);
        }

        syndEntry.setUri(item.getUri());
        syndEntry.setLink(item.getLink());
        syndEntry.setTitle(item.getTitle());
        syndEntry.setLink(item.getLink());
        syndEntry.setSource(createSource(item.getSource()));
        return syndEntry;
    }
View Full Code Here

        return syndEntries;
    }

    protected SyndEntry createSyndEntry(final Entry entry, final boolean preserveWireItem) {

        final SyndEntryImpl syndEntry = new SyndEntryImpl();

        if (preserveWireItem) {
            syndEntry.setWireEntry(entry);
        }

        syndEntry.setModules(ModuleUtils.cloneModules(entry.getModules()));

        final List<Element> foreignMarkup = entry.getForeignMarkup();
        if (Lists.isNotEmpty(foreignMarkup)) {
            syndEntry.setForeignMarkup(foreignMarkup);
        }

        syndEntry.setTitle(entry.getTitle());

        // if there is exactly one alternate link, use that as THE link
        final List<Link> alternateLinks = entry.getAlternateLinks();
        if (Lists.sizeIs(alternateLinks, 1)) {
            final Link theLink = alternateLinks.get(0);
            syndEntry.setLink(theLink.getHrefResolved());
        }

        // Create synd enclosures from enclosure links
        final List<SyndEnclosure> syndEnclosures = new ArrayList<SyndEnclosure>();
        final List<Link> otherLinks = entry.getOtherLinks();
        if (Lists.isNotEmpty(otherLinks)) {
            for (final Link otherLink : otherLinks) {
                final Link thisLink = otherLink;
                if ("enclosure".equals(thisLink.getRel())) {
                    syndEnclosures.add(createSyndEnclosure(entry, thisLink));
                }
            }
        }
        syndEntry.setEnclosures(syndEnclosures);

        // lump alternate and other links together
        final List<SyndLink> syndLinks = new ArrayList<SyndLink>();

        if (Lists.isNotEmpty(alternateLinks)) {
            syndLinks.addAll(createSyndLinks(alternateLinks));
        }

        if (Lists.isNotEmpty(otherLinks)) {
            syndLinks.addAll(createSyndLinks(otherLinks));
        }

        syndEntry.setLinks(syndLinks);

        final String id = entry.getId();
        if (id != null) {
            syndEntry.setUri(id);
        } else {
            final String link = syndEntry.getLink();
            syndEntry.setUri(link);
        }

        Content summary = entry.getSummary();
        if (summary == null) {
            final List<Content> contents = entry.getContents();
            if (Lists.isNotEmpty(contents)) {
                summary = contents.get(0);
            }
        } else {
            final SyndContent sContent = new SyndContentImpl();
            sContent.setType(summary.getType());
            sContent.setValue(summary.getValue());
            syndEntry.setDescription(sContent);
        }

        final List<Content> contents = entry.getContents();
        if (Lists.isNotEmpty(contents)) {
            final List<SyndContent> sContents = new ArrayList<SyndContent>();
            for (final Content content : contents) {
                final SyndContent sContent = new SyndContentImpl();
                sContent.setType(content.getType());
                sContent.setValue(content.getValue());
                sContent.setMode(content.getMode());
                sContents.add(sContent);

            }
            syndEntry.setContents(sContents);
        }

        final List<SyndPerson> authors = entry.getAuthors();
        if (Lists.isNotEmpty(authors)) {
            syndEntry.setAuthors(createSyndPersons(authors));
            final SyndPerson firstPerson = syndEntry.getAuthors().get(0);
            syndEntry.setAuthor(firstPerson.getName());
        }

        Date date = entry.getModified();
        if (date == null) {
            date = Alternatives.firstNotNull(entry.getIssued(), entry.getCreated());
        }

        if (date != null) {
            syndEntry.setPublishedDate(date);
        }

        return syndEntry;
    }
View Full Code Here

        }
        return syndEntries;
    }

    protected SyndEntry createSyndEntry(final Feed feed, final Entry entry, final boolean preserveWireItem) {
        final SyndEntryImpl syndEntry = new SyndEntryImpl();
        if (preserveWireItem) {
            syndEntry.setWireEntry(entry);
        }
        syndEntry.setModules(ModuleUtils.cloneModules(entry.getModules()));

        final List<Element> foreignMarkup = entry.getForeignMarkup();
        if (!foreignMarkup.isEmpty()) {
            syndEntry.setForeignMarkup(foreignMarkup);
        }

        final Content eTitle = entry.getTitleEx();
        if (eTitle != null) {
            syndEntry.setTitleEx(createSyndContent(eTitle));
        }

        final Content summary = entry.getSummary();
        if (summary != null) {
            syndEntry.setDescription(createSyndContent(summary));
        }

        final List<Content> contents = entry.getContents();
        if (Lists.isNotEmpty(contents)) {
            final List<SyndContent> sContents = new ArrayList<SyndContent>();
            for (final Content content : contents) {
                sContents.add(createSyndContent(content));
            }
            syndEntry.setContents(sContents);
        }

        final List<SyndPerson> authors = entry.getAuthors();
        if (Lists.isNotEmpty(authors)) {
            syndEntry.setAuthors(ConverterForAtom03.createSyndPersons(authors));
            final SyndPerson person0 = syndEntry.getAuthors().get(0);
            syndEntry.setAuthor(person0.getName());
        }

        final List<SyndPerson> contributors = entry.getContributors();
        if (Lists.isNotEmpty(contributors)) {
            syndEntry.setContributors(ConverterForAtom03.createSyndPersons(contributors));
        }

        Date date = entry.getPublished();
        if (date != null) {
            syndEntry.setPublishedDate(date);
        }

        date = entry.getUpdated();
        if (date != null) {
            syndEntry.setUpdatedDate(date);
        }

        final List<Category> categories = entry.getCategories();
        if (categories != null) {
            final List<SyndCategory> syndCategories = new ArrayList<SyndCategory>();
            for (final Category category : categories) {
                final SyndCategory syndCategory = new SyndCategoryImpl();
                syndCategory.setName(category.getTerm());
                syndCategory.setTaxonomyUri(category.getSchemeResolved());
                // TODO: categories MAY have labels
                // syndCategory.setLabel(c.getLabel());
                syndCategories.add(syndCategory);
            }
            syndEntry.setCategories(syndCategories);
        }

        // use first alternate link as THE link
        final List<Link> alternateLinks = entry.getAlternateLinks();
        if (Lists.isNotEmpty(alternateLinks)) {
            final Link theLink = alternateLinks.get(0);
            syndEntry.setLink(theLink.getHrefResolved());
        }

        // Create synd enclosures from enclosure links
        final List<SyndEnclosure> syndEnclosures = new ArrayList<SyndEnclosure>();
        final List<Link> otherLinks = entry.getOtherLinks();
        if (Lists.isNotEmpty(otherLinks)) {
            final List<Link> oLinks = otherLinks;
            for (final Link link : oLinks) {
                if ("enclosure".equals(link.getRel())) {
                    syndEnclosures.add(createSyndEnclosure(feed, entry, link));
                }
            }
        }
        syndEntry.setEnclosures(syndEnclosures);

        // lump alternate and other links together
        final List<SyndLink> syndLinks = new ArrayList<SyndLink>();
        if (Lists.isNotEmpty(alternateLinks)) {
            syndLinks.addAll(createSyndLinks(alternateLinks));
        }
        if (Lists.isNotEmpty(otherLinks)) {
            syndLinks.addAll(createSyndLinks(otherLinks));
        }
        syndEntry.setLinks(syndLinks);

        final String id = entry.getId();
        if (id != null) {
            syndEntry.setUri(entry.getId());
        } else {
            syndEntry.setUri(syndEntry.getLink());
        }

        // Convert source element Feed into SyndFeed and assign as SyndEntry
        // source
        final Feed source = entry.getSource();
        if (source != null) {
            final SyndFeed syndSource = new SyndFeedImpl(source);
            syndEntry.setSource(syndSource);
        }

        return syndEntry;
    }
View Full Code Here

        checkFeed(copiedFeed);
    }

    public void testCopiedFeedEntryCategories() throws Exception {
        for (final SyndEntry entry : getCachedSyndFeed().getEntries()) {
            final SyndEntry copiedEntry = new SyndEntryImpl();
            copiedEntry.copyFrom(entry);
            checkEntryCategories(copiedEntry.getCategories());
        }
    }
View Full Code Here

TOP

Related Classes of com.rometools.rome.feed.synd.SyndEntryImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.