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

java.lang.Object
  extended bynet.sourceforge.java.util.jobs.Job
      extended bynet.sourceforge.java.feednread.backend.jobs.NewsFeedParserJob
All Implemented Interfaces:
IJob, IRunnableWithProgress
Direct Known Subclasses:
NewsFeedUpdateJob

public class NewsFeedParserJob
extends Job

Job which parses a NewsFeed either by a given url or a Favorite which houses the url settings.

Author:
Sebastian Machhausen

Field Summary
protected  Favorite favorite
           The Favorite to parse the NewsFeed for
protected  MainApplicationWindow mainWindow
           The Feed'n Read main window
protected  String newsFeedUrl
           The url of the NewsFeed to parse
 
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
NewsFeedParserJob(Favorite favorite, MainApplicationWindow mainWindow)
           Creates a new NewsFeedParserJob to parse the NewsFeed set by the specified Favorite.
NewsFeedParserJob(String newsFeedUrl, MainApplicationWindow mainWindow)
           Creates a new NewsFeedParserJob to parse the NewsFeed at the specified url.
 
Method Summary
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.
private  void parserFailed(LanguageResource resource)
           Called in case this NewsFeedParserJob failed.
private  void parserSucceeded(NewsFeed newsFeed)
           Called in case this NewsFeedParserJob succeeded.
 void run(IProgressMonitor monitor)
           Activates the parsing 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

mainWindow

protected MainApplicationWindow mainWindow

The Feed'n Read main window


newsFeedUrl

protected String newsFeedUrl

The url of the NewsFeed to parse


favorite

protected Favorite favorite

The Favorite to parse the NewsFeed for

Constructor Detail

NewsFeedParserJob

public NewsFeedParserJob(String newsFeedUrl,
                         MainApplicationWindow mainWindow)

Creates a new NewsFeedParserJob to parse the NewsFeed at the specified url.

Parameters:
newsFeedUrl - the url of the NewsFeed to parse
mainWindow - the Feed'n Read main window

NewsFeedParserJob

public NewsFeedParserJob(Favorite favorite,
                         MainApplicationWindow mainWindow)

Creates a new NewsFeedParserJob to parse the NewsFeed set by the specified Favorite.

Parameters:
favorite - the Favorite to parse the NewsFeed for
mainWindow - the Feed'n Read main window
Method Detail

run

public void run(IProgressMonitor monitor)

Activates the parsing process. If the parsing completes correctly and succesfully a new tab is added in the NewsFeedTabBar showing the gui representation of the parsed newsfeed.

If the parsing process failed the reason for that can be queried using the IJob.getException() method.

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

parserSucceeded

private void parserSucceeded(NewsFeed newsFeed)

Called in case this NewsFeedParserJob succeeded. A new tab is added to the NewsFeedTabBar showing the fetched and parsed NewsFeed. In addition a success message is shown in the application status line.

Parameters:
newsFeed - the successfully parsed NewsFeed

parserFailed

private void parserFailed(LanguageResource resource)

Called in case this NewsFeedParserJob failed. An error message is shown in the application status line.

Parameters:
resource - the LanguageResource used

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