de.nava.informa.utils
Class FeedManager

java.lang.Object
  extended by de.nava.informa.utils.FeedManager

public class FeedManager
extends Object

A class used to manage feeds. Feeds are parsed and stored using the addFeed method. Subsequent requests for the same feed URI (using either addFeed or getFeed) will return a cached copy, unless the feed is due to be refreshed direct from the source.
The time before a feed is considered out of date will be read from the feed if possible, failing that a default UpdatePeriod and UpdateFrequency are used.

Version:
$Id: FeedManager.java,v 1.12 2006/12/04 23:43:27 italobb Exp $
Author:
Sam Newman

Constructor Summary
FeedManager()
          Creates a new FeedManager object.
FeedManager(ChannelUpdatePeriod defaultUpdatePeriod, int defaultUpdateFrequency)
          Creates a new FeedManager object.
 
Method Summary
 FeedIF addFeed(FeedIF feed)
          Loads a feed given the metadata information contained in the given FeedIF object
 FeedIF addFeed(FeedIF feed, int ttl)
          Loads a feed given the metadata information contained in the given FeedIF object
 FeedIF addFeed(String feedUri)
          Adds the specified feed to the manager.
 FeedIF addFeed(String feedUri, int wantedTtlmins)
          Adds the specified feed to the manager with a specific Ttl.
 Collection<FeedIF> addFeeds(String opmlFeedUri)
          Attempts to load the feeds specified in the given OPML file into the manager
 Collection<FeedIF> addFeeds(String opmlFeedUri, int ttl)
          Attempts to load the feeds specified in the given OPML file into the manager
 ChannelBuilderIF getChannelBuilder()
          Gets the channel builder used by the feed entries.
 FeedIF getFeed(String feedUri)
          Retrieves the feed being managed.
 boolean hasFeed(String feedUri)
          Determines if the manager is handling the feed
 void removeFeed(String feedUri)
          Removes the specified feed from the manager
 void setChannelBuilder(ChannelBuilderIF chBuilder)
          Sets the channel builder used when reading the news feeds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FeedManager

public FeedManager()
Creates a new FeedManager object.


FeedManager

public FeedManager(ChannelUpdatePeriod defaultUpdatePeriod,
                   int defaultUpdateFrequency)
Creates a new FeedManager object.

Parameters:
defaultUpdatePeriod -
defaultUpdateFrequency -
Method Detail

addFeed

public FeedIF addFeed(FeedIF feed)
               throws FeedManagerException
Loads a feed given the metadata information contained in the given FeedIF object

Parameters:
feed -
Returns:
FeedIF object
Throws:
FeedManagerException - DOCUMENT ME!

addFeed

public FeedIF addFeed(FeedIF feed,
                      int ttl)
               throws FeedManagerException
Loads a feed given the metadata information contained in the given FeedIF object

Parameters:
feed -
ttl - in minutes
Returns:
FeedIF object
Throws:
FeedManagerException - DOCUMENT ME!

addFeeds

public Collection<FeedIF> addFeeds(String opmlFeedUri)
                            throws FeedManagerException
Attempts to load the feeds specified in the given OPML file into the manager

Parameters:
opmlFeedUri - An OPML file containing a list of feeds
Returns:
A list of FeedIF files representing the feeds added
Throws:
FeedManagerException - DOCUMENT ME!

addFeeds

public Collection<FeedIF> addFeeds(String opmlFeedUri,
                                   int ttl)
                            throws FeedManagerException
Attempts to load the feeds specified in the given OPML file into the manager

Parameters:
opmlFeedUri - An OPML file containing a list of feeds
ttl - a ttl for all feeds (in minutes)
Returns:
A list of FeedIF files representing the feeds added
Throws:
FeedManagerException - DOCUMENT ME!

setChannelBuilder

public void setChannelBuilder(ChannelBuilderIF chBuilder)
Sets the channel builder used when reading the news feeds.

Parameters:
chBuilder -

getChannelBuilder

public ChannelBuilderIF getChannelBuilder()
Gets the channel builder used by the feed entries.

Returns:
ChannelBuilderIF

hasFeed

public boolean hasFeed(String feedUri)
Determines if the manager is handling the feed

Parameters:
feedUri - The URI for the feed
Returns:
true if the feed is managed, else false

addFeed

public FeedIF addFeed(String feedUri)
               throws FeedManagerException
Adds the specified feed to the manager. If the feed is already managed nothing happens

Parameters:
feedUri - The URI of the feed to add
Returns:
The feed being managed
Throws:
FeedManagerException - If the feed specified is invalid

addFeed

public FeedIF addFeed(String feedUri,
                      int wantedTtlmins)
               throws FeedManagerException
Adds the specified feed to the manager with a specific Ttl. The ttl specified may superseded the global ttl (deducted from updatePeriod and updateFrequency), depending on the feed type. This behavior is implemented in the differents CacheSettingsIF implementations provided.

Parameters:
feedUri - The URI of the feed to add
wantedTtlmins - The ttl wanted for this feed (in minutes)
Returns:
The feed being managed
Throws:
FeedManagerException - If the feed specified is invalid
See Also:
CacheSettingsIF

removeFeed

public void removeFeed(String feedUri)
Removes the specified feed from the manager

Parameters:
feedUri - The URI for the feed to remove

getFeed

public FeedIF getFeed(String feedUri)
               throws FeedManagerException
Retrieves the feed being managed. Note that null will be returned if the feed is not being managed. If you want to add a feed and return it in the same method, use addFeed instead.

Parameters:
feedUri - The feed to return
Returns:
The feed being managed, or null if the feed is not present
Throws:
FeedManagerException - If the feed specified is invalid


Copyright © 2002-2007 Niko Schmuck. All Rights Reserved.