rss.database
Interface DataSource

All Known Implementing Classes:
HashtableDataSource

public interface DataSource

Interfaced used by all data sources. Only methods in this interface will be called for a given DataSource object. All other methods in an implementing class should be marked as private.

DataSource objects should be able to save their data across application restarts. Hence, a call to saveToFile(String) should write data to the specified file, and loadFromFile(String) should build a new DataSource based on data from a specified file.

Remember when implementing this class to notify listeners of your DataSource object when any changes are made to the DataSource.

Version 1.0: Tree structure for the tree in the GUI is kept within the DataSource.

Author:
Karl E. Rieb

Method Summary
 void addAllFeedItemsToFeed(java.util.Collection<FeedItem> items, Feed feed)
          Adds all the given FeedItems to a specified Feed.
 void addAllFeeds(java.util.Collection<Feed> feeds, TreeFolder folder)
          Adds the given Feeds to a particular folder.
 void addDataListener(DataListener listener)
          Adds a DataListener to the DataSource that is informed whenever any changes are made to the DataSource.
 void addFeed(Feed feed, TreeFolder folder)
          Adds a Feed to a particular folder.
 void addFeedItemToFeed(FeedItem item, Feed feed)
          Adds a FeedItem to a particular Feed.
 java.util.Collection<FeedItem> getAllFeedItems()
          Returns all FeedItems in the DataSource.
 java.util.Collection<Feed> getAllFeeds()
          Returns all Feeds in the DataSource.
 java.util.Collection<FeedItem> getFeedItemsFromFeed(Feed feed)
          Returns all FeedItems contained by the given Feed.
 java.util.Collection<Feed> getFeedsFromFeedItem(FeedItem item)
          Returns all Feeds that contain the given FeedItem.
 RootFolder getRootFolder()
          Returns the stored root folder.
 DataSource loadFromFile(java.lang.String file)
          Creates a new DataSource based on the data from the specified file path.
 void removeAllFeedItems(java.util.Collection<FeedItem> items)
          Removes given FeedItems from the DataSource.
 void removeAllFeedItemsFromFeed(java.util.Collection<FeedItem> items, Feed feed)
          Removes the given FeedItems from the specified Feed.
 void removeAllFeeds(java.util.Collection<Feed> feeds)
          Removes given Feeds from the DataSource.
 void removeDataListener(DataListener listener)
          Removes the DataListener from the list of listeners.
 void removeFeed(Feed feed)
          Removes given Feed from the DataSource.
 void removeFeedFromFolder(Feed feed, TreeFolder folder)
          Removes a Feed from a given folder.
 void removeFeedItem(FeedItem item)
          Removes given FeedItem from the DataSource.
 void removeFeedItemFromFeed(FeedItem item, Feed feed)
          Removes given FeedItem from the specified Feed.
 void saveToFile(java.lang.String file)
          Saves the data in the DataSource to the given file.
 void setRootFolder(RootFolder root)
          Sets the root folder to the given root folder.
 

Method Detail

addAllFeedItemsToFeed

void addAllFeedItemsToFeed(java.util.Collection<FeedItem> items,
                           Feed feed)
Adds all the given FeedItems to a specified Feed.

Parameters:
items - FeedItems to add to a given Feed.
feed - Feed containing the newly added FeedItems.

addAllFeeds

void addAllFeeds(java.util.Collection<Feed> feeds,
                 TreeFolder folder)
Adds the given Feeds to a particular folder.

Parameters:
feeds - Feeds to add to the folder
folder - TreeFolder containing the newly added Feeds

addFeed

void addFeed(Feed feed,
             TreeFolder folder)
Adds a Feed to a particular folder.

Parameters:
feed - Feed to add to the folder
folder - TreeFolder containing the newly added Feed

addFeedItemToFeed

void addFeedItemToFeed(FeedItem item,
                       Feed feed)
Adds a FeedItem to a particular Feed.

Parameters:
item - FeedItem to add to the feed
feed - Feed containing the newly added FeedItem

getAllFeeds

java.util.Collection<Feed> getAllFeeds()
Returns all Feeds in the DataSource.

Returns:
All Feeds in the DataSource

getAllFeedItems

java.util.Collection<FeedItem> getAllFeedItems()
Returns all FeedItems in the DataSource.

Returns:
All FeedItems in the DataSource

getFeedsFromFeedItem

java.util.Collection<Feed> getFeedsFromFeedItem(FeedItem item)
Returns all Feeds that contain the given FeedItem.

Parameters:
item - FeedItem contianed by the feeds
Returns:
All Feeds that contain the given FeedItem

getFeedItemsFromFeed

java.util.Collection<FeedItem> getFeedItemsFromFeed(Feed feed)
Returns all FeedItems contained by the given Feed.

Parameters:
feed - Feed containing the FeedItems
Returns:
All FeedItems contained by the given Feed

removeAllFeedItemsFromFeed

void removeAllFeedItemsFromFeed(java.util.Collection<FeedItem> items,
                                Feed feed)
Removes the given FeedItems from the specified Feed.

Parameters:
items - FeedItems to remove from the feed
feed - Feed containing items to be removed

removeAllFeedItems

void removeAllFeedItems(java.util.Collection<FeedItem> items)
Removes given FeedItems from the DataSource.

Parameters:
items - FeedItems to remove from the DataSource

removeAllFeeds

void removeAllFeeds(java.util.Collection<Feed> feeds)
Removes given Feeds from the DataSource.

Parameters:
feeds - Feeds to remove from the DataSource

removeFeed

void removeFeed(Feed feed)
Removes given Feed from the DataSource.

Parameters:
feed - Feed to remove from the DataSource

removeFeedItem

void removeFeedItem(FeedItem item)
Removes given FeedItem from the DataSource.

Parameters:
item - FeedItem from the DataSource.

removeFeedItemFromFeed

void removeFeedItemFromFeed(FeedItem item,
                            Feed feed)
Removes given FeedItem from the specified Feed.

Parameters:
item - FeedItem to remove from the feed
feed - Feed containing the item to be removed

setRootFolder

void setRootFolder(RootFolder root)
Sets the root folder to the given root folder. Note that copies of the folder should be made.

Parameters:
root - RootFolder to store in the DataSource

getRootFolder

RootFolder getRootFolder()
Returns the stored root folder.

Returns:
RootFolder stored in the DataSource

removeFeedFromFolder

void removeFeedFromFolder(Feed feed,
                          TreeFolder folder)
Removes a Feed from a given folder.

Parameters:
feed - Feed to remove from the folder
folder - TreeFolder containing the feed to be removed

saveToFile

void saveToFile(java.lang.String file)
                throws java.io.IOException
Saves the data in the DataSource to the given file.

Parameters:
file - Path of the file where the data will be saved
Throws:
java.io.IOException - Thrown if there is an error writting to the file path

loadFromFile

DataSource loadFromFile(java.lang.String file)
                        throws java.io.IOException
Creates a new DataSource based on the data from the specified file path.

Parameters:
file - Path of the file where the data is stored
Returns:
DataSource containing data from the file
Throws:
java.io.IOException - Thrown if there is an error reading the file

addDataListener

void addDataListener(DataListener listener)
Adds a DataListener to the DataSource that is informed whenever any changes are made to the DataSource.

Parameters:
listener - DataListener to add as a listener to the the DataSource

removeDataListener

void removeDataListener(DataListener listener)
Removes the DataListener from the list of listeners.

Parameters:
listener - DataListener to remove from list of listeners