Package com.rometools.rome.feed.rss

Examples of com.rometools.rome.feed.rss.Channel


    }

    @Override
    protected WireFeed createRealFeed(final String type, final SyndFeed syndFeed) {

        final Channel channel = (Channel) super.createRealFeed(type, syndFeed);

        final String uri = syndFeed.getUri();
        if (uri != null) {
            channel.setUri(uri);
        } else {
            // if URI is not set use the value for link
            final String link = syndFeed.getLink();
            channel.setUri(link);
        }

        return channel;
    }
View Full Code Here


     * @param rssRoot the root element of the RSS document to parse.
     * @return the parsed Channel bean.
     */
    protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {

        final Channel channel = new Channel(getType());
        channel.setStyleSheet(getStyleSheet(rssRoot.getDocument()));

        final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());

        final Element title = eChannel.getChild("title", getRSSNamespace());
        if (title != null) {
            channel.setTitle(title.getText());
        }

        final Element link = eChannel.getChild("link", getRSSNamespace());
        if (link != null) {
            channel.setLink(link.getText());
        }

        final Element description = eChannel.getChild("description", getRSSNamespace());
        if (description != null) {
            channel.setDescription(description.getText());
        }

        channel.setImage(parseImage(rssRoot));

        channel.setTextInput(parseTextInput(rssRoot));

        // Unfortunately Microsoft's SSE extension has a special case of effectively putting the
        // sharing channel module inside the RSS tag and not inside the channel itself. So we also
        // need to look for channel modules from the root RSS element.
        final List<Module> allFeedModules = new ArrayList<Module>();
        final List<Module> rootModules = parseFeedModules(rssRoot, locale);
        final List<Module> channelModules = parseFeedModules(eChannel, locale);

        if (rootModules != null) {
            allFeedModules.addAll(rootModules);
        }

        if (channelModules != null) {
            allFeedModules.addAll(channelModules);
        }

        channel.setModules(allFeedModules);
        channel.setItems(parseItems(rssRoot, locale));

        final List<Element> foreignMarkup = extractForeignMarkup(eChannel, channel, getRSSNamespace());
        if (!foreignMarkup.isEmpty()) {
            channel.setForeignMarkup(foreignMarkup);
        }

        return channel;

    }
View Full Code Here

        syndFeed.setStyleSheet(feed.getStyleSheet());

        syndFeed.setEncoding(feed.getEncoding());

        final Channel channel = (Channel) feed;

        syndFeed.setTitle(channel.getTitle());
        syndFeed.setLink(channel.getLink());
        syndFeed.setDescription(channel.getDescription());

        final Image image = channel.getImage();
        if (image != null) {
            syndFeed.setImage(createSyndImage(image));
        }

        final List<Item> items = channel.getItems();
        if (items != null) {
            syndFeed.setEntries(createSyndEntries(items, syndFeed.isPreservingWireFeed()));
        }
    }
View Full Code Here

    public WireFeed createRealFeed(final SyndFeed syndFeed) {
        return this.createRealFeed(getType(), syndFeed);
    }

    protected WireFeed createRealFeed(final String type, final SyndFeed syndFeed) {
        final Channel channel = new Channel(type);
        channel.setModules(ModuleUtils.cloneModules(syndFeed.getModules()));
        channel.setStyleSheet(syndFeed.getStyleSheet());
        channel.setEncoding(syndFeed.getEncoding());

        channel.setTitle(syndFeed.getTitle());
        final String link = syndFeed.getLink();
        final List<SyndLink> links = syndFeed.getLinks();
        if (link != null) {
            channel.setLink(link);
        } else if (!links.isEmpty()) {
            channel.setLink(links.get(0).getHref());
        }

        channel.setDescription(syndFeed.getDescription());

        final SyndImage sImage = syndFeed.getImage();
        if (sImage != null) {
            channel.setImage(createRSSImage(sImage));
        }

        final List<SyndEntry> sEntries = syndFeed.getEntries();
        if (sEntries != null) {
            channel.setItems(createRSSItems(sEntries));
        }

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

        return channel;
    }
View Full Code Here

    }

    @Override
    protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {

        final Channel channel = (Channel) super.parseChannel(rssRoot, locale);

        final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());

        final Element eCloud = eChannel.getChild("cloud", getRSSNamespace());

        if (eCloud != null) {
            final Cloud cloud = new Cloud();

            final String domain = eCloud.getAttributeValue("domain");
            if (domain != null) {
                cloud.setDomain(domain);
            }

            // getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
            final String port = eCloud.getAttributeValue("port");
            if (port != null) {
                cloud.setPort(Integer.parseInt(port.trim()));
            }

            // getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
            final String path = eCloud.getAttributeValue("path");
            if (path != null) {
                cloud.setPath(path);
            }

            // getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
            final String registerProcedure = eCloud.getAttributeValue("registerProcedure");
            if (registerProcedure != null) {
                cloud.setRegisterProcedure(registerProcedure);
            }

            // getRSSNamespace()); DONT KNOW WHY DOESN'T WORK
            final String protocol = eCloud.getAttributeValue("protocol");
            if (protocol != null) {
                cloud.setProtocol(protocol);
            }

            channel.setCloud(cloud);

        }
        return channel;
    }
View Full Code Here

    }

    @Override
    protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {

        final Channel channel = (Channel) super.parseChannel(rssRoot, locale);

        final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());

        final List<Element> categories = eChannel.getChildren("category", getRSSNamespace());
        channel.setCategories(parseCategories(categories));

        final Element ttl = eChannel.getChild("ttl", getRSSNamespace());
        if (ttl != null && ttl.getText() != null) {
            final Integer ttlValue = NumberParser.parseInt(ttl.getText());
            if (ttlValue != null) {
                channel.setTtl(ttlValue);
            }
        }

        return channel;
    }
View Full Code Here

     * @return the parsed Channel bean.
     */
    @Override
    protected WireFeed parseChannel(final Element rssRoot, final Locale locale) {

        final Channel channel = (Channel) super.parseChannel(rssRoot, locale);

        final Element eChannel = rssRoot.getChild("channel", getRSSNamespace());

        final Element language = eChannel.getChild("language", getRSSNamespace());
        if (language != null) {
            channel.setLanguage(language.getText());
        }

        final Element atinge = eChannel.getChild("rating", getRSSNamespace());
        if (atinge != null) {
            channel.setRating(atinge.getText());
        }

        final Element copyright = eChannel.getChild("copyright", getRSSNamespace());
        if (copyright != null) {
            channel.setCopyright(copyright.getText());
        }

        final Element pubDate = eChannel.getChild("pubDate", getRSSNamespace());
        if (pubDate != null) {
            channel.setPubDate(DateParser.parseDate(pubDate.getText(), locale));
        }

        final Element lastBuildDate = eChannel.getChild("lastBuildDate", getRSSNamespace());
        if (lastBuildDate != null) {
            channel.setLastBuildDate(DateParser.parseDate(lastBuildDate.getText(), locale));
        }

        final Element docs = eChannel.getChild("docs", getRSSNamespace());
        if (docs != null) {
            channel.setDocs(docs.getText());
        }

        final Element generator = eChannel.getChild("generator", getRSSNamespace());
        if (generator != null) {
            channel.setGenerator(generator.getText());
        }

        final Element managingEditor = eChannel.getChild("managingEditor", getRSSNamespace());
        if (managingEditor != null) {
            channel.setManagingEditor(managingEditor.getText());
        }

        final Element webMaster = eChannel.getChild("webMaster", getRSSNamespace());
        if (webMaster != null) {
            channel.setWebMaster(webMaster.getText());
        }

        final Element eSkipHours = eChannel.getChild("skipHours");
        if (eSkipHours != null) {
            final List<Integer> skipHours = new ArrayList<Integer>();
            final List<Element> eHours = eSkipHours.getChildren("hour", getRSSNamespace());
            for (final Element eHour : eHours) {
                skipHours.add(new Integer(eHour.getText().trim()));
            }
            channel.setSkipHours(skipHours);
        }

        final Element eSkipDays = eChannel.getChild("skipDays");
        if (eSkipDays != null) {
            final List<String> skipDays = new ArrayList<String>();
            final List<Element> eDays = eSkipDays.getChildren("day", getRSSNamespace());
            for (final Element eDay : eDays) {
                skipDays.add(eDay.getText().trim());
            }
            channel.setSkipDays(skipDays);
        }

        return channel;
    }
View Full Code Here

    }

    @Override
    public void copyInto(final WireFeed feed, final SyndFeed syndFeed) {

        final Channel channel = (Channel) feed;

        super.copyInto(channel, syndFeed);

        syndFeed.setLanguage(channel.getLanguage()); // c

        syndFeed.setCopyright(channel.getCopyright()); // c

        syndFeed.setDocs(channel.getDocs());

        syndFeed.setManagingEditor(channel.getManagingEditor());

        syndFeed.setWebMaster(channel.getWebMaster());

        syndFeed.setGenerator(channel.getGenerator());

        final Date pubDate = channel.getPubDate();

        if (pubDate != null) {
            syndFeed.setPublishedDate(pubDate); // c
        } else if (channel.getLastBuildDate() != null) {
            syndFeed.setPublishedDate(channel.getLastBuildDate()); // c
        }

        final String author = channel.getManagingEditor();

        if (author != null) {

            final List<String> creators = ((DCModule) syndFeed.getModule(DCModule.URI)).getCreators();
View Full Code Here

        return item;
    }

    @Override
    protected WireFeed createRealFeed(final String type, final SyndFeed syndFeed) {
        final Channel channel = (Channel) super.createRealFeed(type, syndFeed);
        channel.setLanguage(syndFeed.getLanguage()); // c
        channel.setCopyright(syndFeed.getCopyright()); // c
        channel.setPubDate(syndFeed.getPublishedDate()); // c
        channel.setDocs(syndFeed.getDocs());
        channel.setManagingEditor(syndFeed.getManagingEditor());
        channel.setWebMaster(syndFeed.getWebMaster());
        channel.setGenerator(syndFeed.getGenerator());

        final List<SyndPerson> authors = syndFeed.getAuthors();
        if (Lists.isNotEmpty(authors)) {
            final SyndPerson author = authors.get(0);
            channel.setManagingEditor(author.getName());
        }

        return channel;
    }
View Full Code Here

        super(type);
    }

    @Override
    public Document generate(final WireFeed feed) throws FeedException {
        final Channel channel = (Channel) feed;
        final Element root = createRootElement(channel);
        populateFeed(channel, root);
        purgeUnusedNamespaceDeclarations(root);
        return createDocument(root);
    }
View Full Code Here

TOP

Related Classes of com.rometools.rome.feed.rss.Channel

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.