net.sourceforge.java.feednread.backend.jobs
Class NewsFeedAggregatorJob

java.lang.Object
  extended bynet.sourceforge.java.util.jobs.Job
      extended bynet.sourceforge.java.feednread.backend.jobs.NewsFeedAggregatorJob
All Implemented Interfaces:
IJob, IRunnableWithProgress

public class NewsFeedAggregatorJob
extends Job

Job to aggregate a single Favrite i.e. its set NewsFeed into a given AggregatedNewsFeed. The Job reports to a higher coordinating NewsFeedAggregationManagerJob.

Author:
Sebastian Machhausen

Field Summary
private  NewsFeedAggregationManagerJob aggregationMgr
           The coordinating aggregation manager
private  AggregatedNewsFeed newsFeed
           The AggregatedNewsFeed instance that the Job adds its parsed NewsFeedEntries to
private  Favorite newsFeedFavorite
           The Favorite to aggregate
 
Fields inherited from class net.sourceforge.java.util.jobs.Job
 
Fields inherited from interface net.sourceforge.java.util.jobs.IJob
HIGH_PRIORITY, LOW_PRIORITY, NORM_PRIORITY
 
Constructor Summary
NewsFeedAggregatorJob(Favorite newsFeedFavorite, NewsFeedAggregationManagerJob aggregationMgr, AggregatedNewsFeed newsFeed)
           Creates a new NewsFeedAggregatorJob that adds the parsed entries of the sepcified newsfeed Favorite to the specified aggregated newsFeed.
 
Method Summary
 Favorite getFavorite()
           Gets the newsfeed Favorite parsed/aggregated by this NewsFeedAggregatorJob
protected  NewsFeed getNewsFeedFromCache(URL feedUrl)
           Gets the the cached NewsFeed or null if the NewsFeed is not in cache
protected  NewsFeed parseNewsFeed(IProgressMonitor monitor)
           Parses the newsfeed into a NewsFeed representation.
 void run(IProgressMonitor monitor)
           Activates the parsing respectively aggregation process.
 
Methods inherited from class net.sourceforge.java.util.jobs.Job
cancel, done, getException, getJobManager, getName, getPriority, getStatus, getThread, isCanceled, join, setException, setJobManager, setName, setPriority, setThread, start, started, statusChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

aggregationMgr

private NewsFeedAggregationManagerJob aggregationMgr

The coordinating aggregation manager


newsFeedFavorite

private Favorite newsFeedFavorite

The Favorite to aggregate


newsFeed

private AggregatedNewsFeed newsFeed

The AggregatedNewsFeed instance that the Job adds its parsed NewsFeedEntries to

Constructor Detail

NewsFeedAggregatorJob

public NewsFeedAggregatorJob(Favorite newsFeedFavorite,
                             NewsFeedAggregationManagerJob aggregationMgr,
                             AggregatedNewsFeed newsFeed)

Creates a new NewsFeedAggregatorJob that adds the parsed entries of the sepcified newsfeed Favorite to the specified aggregated newsFeed. In addition it notifies the enclosing and coordinating NewsFeedAggregationManagerJob when then parsing of the newsfeed finished.

Parameters:
newsFeedFavorite - the newsfeed Favorite to aggregate
aggregationMgr - the coordinating NewsFeedAggregationManagerJob
newsFeed - the newsfeed to aggregate into
Method Detail

run

public void run(IProgressMonitor monitor)

Activates the parsing respectively aggregation process.

Parameters:
monitor - the IProgressMonitor to use for reporting the progress of this NewsFeedAggregatorJob
See Also:
IRunnableWithProgress.run(org.eclipse.core.runtime.IProgressMonitor)

getFavorite

public Favorite getFavorite()

Gets the newsfeed Favorite parsed/aggregated by this NewsFeedAggregatorJob

Returns:
the newsfeed Favorite parsed/aggregated by this NewsFeedAggregatorJob

parseNewsFeed

protected NewsFeed parseNewsFeed(IProgressMonitor monitor)
                          throws MalformedURLException,
                                 IOException,
                                 FeedException,
                                 FetcherException

Parses the newsfeed into a NewsFeed representation.

Parameters:
monitor - the IProgressMonitor to use for reporting the progress of this NewsFeedParserJob
Returns:
the NewsFeed representation
Throws:
MalformedURLException - if the newsfeed url is invalid
IOException - if an io error occured during parsing
FeedException - if the newsfeed could not be parsed correctly
FetcherException - if the newsfeed could not be fetched

getNewsFeedFromCache

protected NewsFeed getNewsFeedFromCache(URL feedUrl)

Gets the the cached NewsFeed or null if the NewsFeed is not in cache

Parameters:
feedUrl - the URL of the NewsFeed to get from the cache
Returns:
the cached NewsFeed or null if the NewsFeed is not in cache