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

The following examples show how to use com.rometools.rome.feed.rss.Channel#setCategories() . 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: RSS094Parser.java    From rome with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 2
Source File: ConverterForRSS094.java    From rome with Apache License 2.0 5 votes vote down vote up
@Override
protected WireFeed createRealFeed(final String type, final SyndFeed syndFeed) {
    final Channel channel = (Channel) super.createRealFeed(type, syndFeed);
    final List<SyndCategory> cats = syndFeed.getCategories(); // c
    if (!cats.isEmpty()) {
        channel.setCategories(createRSSCategories(cats));
    }
    return channel;
}