edu.cmu.ri.createlab.rss
Class RSSReader

java.lang.Object
  extended by edu.cmu.ri.createlab.rss.RSSReader
Direct Known Subclasses:
EarthquakeReader, MovieReader, NewsReader, StockReader, TuneReader, WeatherReader, WOTDReader

public class RSSReader
extends Object

RSSReader can be used to generally access RSS feeds.

Author:
Tom Lauwers (tlauwers@andrew.cmu.edu), Chris Bartley (bartley@cmu.edu)

Constructor Summary
RSSReader(String URLFeed)
          Constructs the reader object by providing a URL which points to an RSS or Atom feed.
 
Method Summary
 List<FeedEntry> getEntries()
          Returns (a copy of) the entries in the feed (since the last update).
 List<FeedEntry> getEntriesPublishedAfterTimestamp(long timestamp)
          Returns the entries in the feed (since the last update) which were published after the given timestamp.
 String getEntryAuthor(int index)
          Returns the first author of the feed entry specified by index.
 int getEntryCount()
          Returns the total number of feed entries as an int
 Date getEntryDate(int index)
          Get the date the entry was published specified by index.
 String getEntryDescription(int index)
          Returns the entry's text description specified by index.
 String getEntryLink(int index)
          Returns the link to the feed entry specified by index.
 String getEntryTitle(int index)
          Returns the title of the feed entry specified by index.
 String getFeedAuthor()
          Returns the name of the first author of the feed as a String
 Date getFeedDate(int index)
          Returns the date the feed was published as a Date object
 String getFeedDescription()
          Returns a description of the feed as a String
 String getFeedLink()
          Returns the URL of the feed as a String
 String getFeedTitle()
          Returns the title of the feed as a String
 void updateFeed()
          Fetches the data from the web and updates all of the feed's data
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RSSReader

public RSSReader(String URLFeed)
Constructs the reader object by providing a URL which points to an RSS or Atom feed.

Parameters:
URLFeed - Holds the loction of the URL location of the RSS feed. For example, 'http://rss.news.yahoo.com/rss/topstories'
Method Detail

updateFeed

public void updateFeed()
Fetches the data from the web and updates all of the feed's data


getFeedAuthor

public String getFeedAuthor()
Returns the name of the first author of the feed as a String

Returns:
The author of the feed

getFeedTitle

public String getFeedTitle()
Returns the title of the feed as a String

Returns:
The title of the feed

getFeedLink

public String getFeedLink()
Returns the URL of the feed as a String

Returns:
The URL link of the feed

getFeedDescription

public String getFeedDescription()
Returns a description of the feed as a String

Returns:
The description of the feed

getFeedDate

public Date getFeedDate(int index)
Returns the date the feed was published as a Date object

Returns:
The date the feed was published

getEntryCount

public int getEntryCount()
Returns the total number of feed entries as an int

Returns:
The number of feed entries

getEntries

public List<FeedEntry> getEntries()
Returns (a copy of) the entries in the feed (since the last update).

Returns:
a copy of the entries in the feed since the last update.

getEntriesPublishedAfterTimestamp

public List<FeedEntry> getEntriesPublishedAfterTimestamp(long timestamp)
Returns the entries in the feed (since the last update) which were published after the given timestamp. Returns an empty List if no such entries are found. Guaranteed to not return null.

Returns:
a copy of the entries in the feed since the last update which were published after the given timestamp.

getEntryAuthor

public String getEntryAuthor(int index)
Returns the first author of the feed entry specified by index.

Parameters:
index - Specifies which entry to get data from
Returns:
The first author of the feed entry
Throws:
IndexOutOfBoundsException - if the given index is out of range

getEntryTitle

public String getEntryTitle(int index)
Returns the title of the feed entry specified by index.

Parameters:
index - Specifies which entry to get data from
Returns:
The title of the feed entry
Throws:
IndexOutOfBoundsException - if the given index is out of range

getEntryLink

public String getEntryLink(int index)
Returns the link to the feed entry specified by index.

Parameters:
index - Specifies which entry to get data from
Returns:
The link of the feed entry
Throws:
IndexOutOfBoundsException - if the given index is out of range

getEntryDescription

public String getEntryDescription(int index)
Returns the entry's text description specified by index.

Parameters:
index - Specifies which entry to get data from
Returns:
The description of the feed entry
Throws:
IndexOutOfBoundsException - if the given index is out of range

getEntryDate

public Date getEntryDate(int index)
Get the date the entry was published specified by index.

Parameters:
index - Specifies which entry to get data from
Returns:
The publication date of the feed entry
Throws:
IndexOutOfBoundsException - if the given index is out of range