parser
Class RomeFeedParser

java.lang.Object
  extended by parser.RomeFeedParser

public class RomeFeedParser
extends java.lang.Object


Constructor Summary
RomeFeedParser()
           
 
Method Summary
private static com.sun.syndication.feed.synd.SyndFeed getURL(java.lang.String url)
           
static void main(java.lang.String[] args)
           
static java.lang.String MakeOPMLString(java.util.List<Feed> feeds)
          Given a list of feeds, creates a OPML outline that represents those feeds.
static java.lang.String MakeRSSString(Feed f, java.lang.String outputType)
          Creates a syndication-feed string in the requested output format from a given feed.
private static Feed ParseFeed(com.sun.syndication.feed.synd.SyndFeed feed)
          Internal method: takes as input a feed to be parsed and outputs the Feed object (constructed with no id) containing all the useful information in the Rome SyndFeed object passed to it.
private static java.util.List<java.lang.String> ParseOPML(com.sun.syndication.feed.opml.Opml feed)
           
static java.util.List<java.lang.String> ParseOPMLFile(java.lang.String filename)
          Using the Rome OPML module, this method parses a user-supplied OPML file (on local drive) and returns a list of strings.
static java.util.List<java.lang.String> ParseOPMLURL(java.lang.String url)
          Using the Rome OPML module, this method parses a user-supplied OPML file (given its URL) and returns a list of strings.
static Feed ParseURL(java.lang.String inputFeedURL)
          The method ParseURL creates and returns a new feed object instantiated with article objects for each of the entries contained within the feed located at the supplied input feed URL.
static void PrintRSSFeed(Feed f)
          "Exports" (prints to stdout) a feed object in RSS 2.0 format.
static void PrintRSSFeed(Feed f, java.lang.String outputType)
          "Exports" (prints to stdout) a feed object in a user-supplied format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RomeFeedParser

public RomeFeedParser()
Method Detail

main

public static void main(java.lang.String[] args)

getURL

private static com.sun.syndication.feed.synd.SyndFeed getURL(java.lang.String url)
                                                      throws java.net.MalformedURLException,
                                                             com.sun.syndication.io.FeedException,
                                                             java.io.IOException
Throws:
java.net.MalformedURLException
com.sun.syndication.io.FeedException
java.io.IOException

ParseURL

public static Feed ParseURL(java.lang.String inputFeedURL)
                     throws java.net.MalformedURLException,
                            java.io.IOException,
                            com.sun.syndication.io.FeedException
The method ParseURL creates and returns a new feed object instantiated with article objects for each of the entries contained within the feed located at the supplied input feed URL.

Parameters:
inputFeedURL - URL (as string) where feed is located.
Returns:
New feed object, containing articles for each entry in the feed.
Throws:
java.net.MalformedURLException - If input URL is malformed (not a valid URL), throws this exception.
java.io.IOException - If the parser has difficulty downloading the feed file, throws this exception. Note that this could happen for a variety of reasons: no Net connection, Web site doesn't exist, file doesn't exist on site, your router ate some packets...
com.sun.syndication.io.FeedException - If Rome can't build a feed from the given RSS feed, this exception will be thrown.

ParseFeed

private static Feed ParseFeed(com.sun.syndication.feed.synd.SyndFeed feed)
                       throws com.sun.syndication.io.FeedException
Internal method: takes as input a feed to be parsed and outputs the Feed object (constructed with no id) containing all the useful information in the Rome SyndFeed object passed to it.

Parameters:
feed -
Returns:
Throws:
com.sun.syndication.io.FeedException

PrintRSSFeed

public static void PrintRSSFeed(Feed f,
                                java.lang.String outputType)
                         throws java.lang.IllegalAccessException,
                                com.sun.syndication.io.FeedException,
                                java.io.IOException
"Exports" (prints to stdout) a feed object in a user-supplied format. This means that the feed will be printed out with as much metadata as this parser takes in when creating Feed objects. The feed will contain all the articles with their available Rome-compatible metadata in their exported XML file.

Parameters:
f - The Feed object to be printed to stdout.
outputType - The type of output feed desired. Rome supports RSS 0.9, 0.91, 0.92, 0.93, 0.94, 1.0, 2.0, and Atom 0.3 and 1.0.
Throws:
java.lang.IllegalAccessException
com.sun.syndication.io.FeedException
java.io.IOException

MakeRSSString

public static java.lang.String MakeRSSString(Feed f,
                                             java.lang.String outputType)
                                      throws java.lang.IllegalAccessException,
                                             com.sun.syndication.io.FeedException,
                                             java.io.IOException
Creates a syndication-feed string in the requested output format from a given feed. Valid output formats are rss_0.9, rss_0.91, rss_0.92, rss_0.93, rss_0.94, rss_1.0, rss_2.0, atom_0.3, or atom_1.0. If you're not sure, choose RSS 2.0.

Parameters:
f - The feed object which is to be created into a feed string
outputType - Output format (a string with a limited set of options dictated by the Rome parser used.)
Returns:
A string containing the
Throws:
java.lang.IllegalAccessException - Thrown if an RSS feed's children cannot be gotten
com.sun.syndication.io.FeedException - Thrown if Rome could not generate output string from these feeds.
java.io.IOException

MakeOPMLString

public static java.lang.String MakeOPMLString(java.util.List<Feed> feeds)
Given a list of feeds, creates a OPML outline that represents those feeds. This is returned as a single long string (which could be, for instance, saved to file). The generated OPML (1.0) is roughly standards-compliant; feedvalidator.org likes it. However, the OPML spec is so young that it's impossible to guarantee this will still be good years down the road.

Parameters:
feeds - List of feeds to be turned into OPML outline elements.
Returns:

PrintRSSFeed

public static void PrintRSSFeed(Feed f)
                         throws com.sun.syndication.io.FeedException,
                                java.io.IOException,
                                java.lang.IllegalAccessException
"Exports" (prints to stdout) a feed object in RSS 2.0 format. This means that the feed will be printed out with as much metadata as this parser takes in when creating Feed objects. The feed will contain all the articles with their available Rome-compatible metadata in their exported XML file.

Parameters:
f - The Feed object to be printed to stdout.
Throws:
com.sun.syndication.io.FeedException
java.io.IOException
java.lang.IllegalAccessException

ParseOPMLURL

public static java.util.List<java.lang.String> ParseOPMLURL(java.lang.String url)
                                                     throws java.net.MalformedURLException,
                                                            java.io.IOException,
                                                            com.sun.syndication.io.FeedException
Using the Rome OPML module, this method parses a user-supplied OPML file (given its URL) and returns a list of strings. Each string is a URL embedded in the OPML file. This parsing treats OPML files in their most frequently used capacity, as a list of links. It discards most other information. This parsing uses a custom user-agent to evade the 403 error which some Web sites provide to Java Web clients (and because our user agent is more informative than "Java 1.5.0.6".) Rome's OPML parsing is not guaranteed good; it's unstable.

Parameters:
filename -
Returns:
Throws:
java.net.MalformedURLException
java.io.IOException
com.sun.syndication.io.FeedException

ParseOPMLFile

public static java.util.List<java.lang.String> ParseOPMLFile(java.lang.String filename)
                                                      throws java.io.IOException,
                                                             com.sun.syndication.io.FeedException
Using the Rome OPML module, this method parses a user-supplied OPML file (on local drive) and returns a list of strings. Each string is a URL embedded in the OPML file. This parsing treats OPML files in their most frequently used capacity, as a list of links. It discards most other information. Rome's OPML parsing is not guaranteed good; it's unstable.

Parameters:
filename -
Returns:
Throws:
java.net.MalformedURLException
java.io.IOException
com.sun.syndication.io.FeedException

ParseOPML

private static java.util.List<java.lang.String> ParseOPML(com.sun.syndication.feed.opml.Opml feed)