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

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

public class DownloadJob
extends Job

Downloads a web based resource to a File on the local machine.

Author:
Sebastian Machhausen

Field Summary
private  URL downloadUrl
           The Url of the File to download
private  boolean podcast
           true if the download specifies a podcast; false otherwise
private  long size
           The size of the download in bytes
private  File targetDirectory
           The target directory to store the downloaded file to
 
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
DownloadJob(URL downloadUrl, File targetDirectory)
           Creates a new DownloadJob which requests the File specified through downloadUrl and stores it in the directory specified by targetDirectory.
DownloadJob(URL downloadUrl, File targetDirectory, boolean podcast)
           Creates a new DownloadJob which requests the File specified through downloadUrl and stores it in the directory specified by targetDirectory.
DownloadJob(URL downloadUrl, File targetDirectory, long size)
           Creates a new DownloadJob which requests the File specified through downloadUrl and stores it in the directory specified by targetDirectory.
DownloadJob(URL downloadUrl, File targetDirectory, long size, boolean podcast)
           Creates a new DownloadJob which requests the File specified through downloadUrl and stores it in the directory specified by targetDirectory.
 
Method Summary
 void run(IProgressMonitor monitor)
           Starts this DownloadJob, i.e. starts the download 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

downloadUrl

private URL downloadUrl

The Url of the File to download


targetDirectory

private File targetDirectory

The target directory to store the downloaded file to


size

private long size

The size of the download in bytes


podcast

private boolean podcast

true if the download specifies a podcast; false otherwise

Constructor Detail

DownloadJob

public DownloadJob(URL downloadUrl,
                   File targetDirectory)
            throws IOException

Creates a new DownloadJob which requests the File specified through downloadUrl and stores it in the directory specified by targetDirectory.

Parameters:
downloadUrl - the url of the file to download
targetDirectory - the directory to store the downloaded file to
Throws:
IOException - if the specified targetDirectory does not a directory, does not exist or is not writeable

DownloadJob

public DownloadJob(URL downloadUrl,
                   File targetDirectory,
                   long size)
            throws IOException

Creates a new DownloadJob which requests the File specified through downloadUrl and stores it in the directory specified by targetDirectory.

Parameters:
downloadUrl - the url of the file to download
targetDirectory - the directory to store the downloaded file to
size - the size of the download in bytes
Throws:
IOException - if the specified targetDirectory does not a directory, does not exist or is not writeable

DownloadJob

public DownloadJob(URL downloadUrl,
                   File targetDirectory,
                   boolean podcast)
            throws IOException

Creates a new DownloadJob which requests the File specified through downloadUrl and stores it in the directory specified by targetDirectory.

Parameters:
downloadUrl - the url of the file to download
targetDirectory - the directory to store the downloaded file to
podcast - true if downloadUrl specifies a podcast; false otherwise
Throws:
IOException - if the specified targetDirectory does not a directory, does not exist or is not writeable

DownloadJob

public DownloadJob(URL downloadUrl,
                   File targetDirectory,
                   long size,
                   boolean podcast)
            throws IOException

Creates a new DownloadJob which requests the File specified through downloadUrl and stores it in the directory specified by targetDirectory.

Parameters:
downloadUrl - the url of the file to download
targetDirectory - the directory to store the downloaded file to
size - the size of the download in bytes
podcast - true if downloadUrl specifies a podcast; false otherwise
Throws:
IOException - if the specified targetDirectory does not a directory, does not exist or is not writeable
Method Detail

run

public void run(IProgressMonitor monitor)
         throws InvocationTargetException,
                InterruptedException

Starts this DownloadJob, i.e. starts the download process.

Parameters:
monitor - the IProgressMonitor to report the progress of the download operation to
Throws:
InvocationTargetException - if an error occured while performing the download process
InterruptedException - if this DownloadJob was interrupted by another IJob
See Also:
Job.getException()