Java Code Examples for com.rometools.rome.feed.rss.Channel#setForeignMarkup()

The following examples show how to use com.rometools.rome.feed.rss.Channel#setForeignMarkup() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConverterForRSS090.java    From rome with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 2
Source File: RSS090Parser.java    From rome with Apache License 2.0 4 votes vote down vote up
/**
 * Parses the root element of an RSS document into a Channel bean.
 * <p/>
 * It reads title, link and description and delegates to parseImage, parseItems and
 * parseTextInput. This delegation always passes the root element of the RSS document as
 * different RSS version may have this information in different parts of the XML tree (no
 * assumptions made thanks to the specs variaty)
 * <p/>
 *
 * @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;

}