magpiebrain

Sam Newman's site, a Consultant at ThoughtWorks

From my forthcoming RSS-Java article – assuming it gets published! Actually this is as much to make sure the code formatting is still working…


package org.safedataco.example;

import de.nava.informa.core.ChannelFormat;
import de.nava.informa.core.ChannelIF;
import de.nava.informa.core.ChannelParserIF;
import de.nava.informa.core.ParseException;
import de.nava.informa.core.UnsupportedFormatException;
import de.nava.informa.impl.basic.ChannelBuilder;
import de.nava.informa.utils.ChannelParserCollection;
import de.nava.informa.utils.FormatDetector;

import java.net.MalformedURLException;
import java.net.URL;


/**
 * An exmaple of Informa's usage
 * @author sam
 */
public class InformaExample {
    public static void main(String[] args) {
        try {
            URL feed =
new URL("file:/C:/java/informa/samples/linuxjournal.rss");
            ChannelParserCollection parsers =
ChannelParserCollection.getInstance();

            ChannelFormat format = FormatDetector.getFormat(feed);
            ChannelParserIF parser = parsers.getParser(format, feed);
            parser.setBuilder(new ChannelBuilder());
            ChannelIF channel = parser.parse();
        } catch (MalformedURLException mue) {
            mue.printStackTrace();
        } catch (UnsupportedFormatException ufe) {
            ufe.printStackTrace();
        } catch (ParseException pe) {
            pe.printStackTrace();
        }
    }
}


Advertisements

2 Responses to “Code teaser”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Basic HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS

%d bloggers like this: